mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-30 19:23:57 +00:00
refs #24010, refs https://github.com/nim-lang/Nim/issues/24125#issuecomment-2358377076 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.
11 lines
357 B
Nim
11 lines
357 B
Nim
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')]#
|