Files
Nim/tests/errmsgs/tgenericmismatchsegfault.nim
metagn ff005ad7dc fix segfault in generic param mismatch error, skip typedesc (#24140)
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.
2024-09-19 07:19:07 +02:00

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]#