mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-12 14:23:45 +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.
14 lines
384 B
Nim
14 lines
384 B
Nim
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]#
|