-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix segfault in generic param mismatch error, skip typedesc (#24140)
refs #24010, refs #24125 (comment) The generic mismatch errors added in #24010 made it possible for `nArg` to be `nil` in the error reporting since it checked the call argument list, not the generic parameter list for the mismatching argument node, which causes a segfault. This is fixed by checking the generic parameter list immediately on any generic mismatch error. Also the `typedesc` type is skipped for the value of the generic params since it's redundant and the generic parameter constraints don't have it.
- Loading branch information
Showing
5 changed files
with
44 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
discard """ | ||
matrix: "-d:testsConciseTypeMismatch" | ||
""" | ||
|
||
template v[T](c: SomeOrdinal): T = T(c) | ||
discard v[int, char]('A') #[tt.Error | ||
^ type mismatch | ||
Expression: v[int, char]('A') | ||
[1] 'A': char | ||
Expected one of (first mismatch at [position]): | ||
[2] template v[T](c: SomeOrdinal): T | ||
generic parameter mismatch, expected SomeOrdinal but got 'char' of type: char]# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
template v[T](c: SomeOrdinal): T = T(c) | ||
discard v[int, char]('A') #[tt.Error | ||
^ type mismatch: got <char> | ||
but expected one of: | ||
template v[T](c: SomeOrdinal): T | ||
first type mismatch at position: 2 in generic parameters | ||
required type for SomeOrdinal: SomeOrdinal | ||
but expression 'char' is of type: char | ||
expression: v[int, char]('A')]# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters