Open ggb-sw opened 1 year ago
The implicit generic from the func_proto
proc type is likely not lifted to the proc it's used for a parameter of (but I might be wrong).
proc tfunc(val: int) : bool =
let i = int(val)
i mod 5 == 0
proc test(val2: int | char, fun: proc (_: int | char): bool) : bool =
fun(val2)
echo test(123, tfunc)
Error: internal error: getTypeDescAux(tyOr)
As another example of an implicit generic type nested in a concrete type (ignoring proc type generic parameter list association weirdness), this also doesn't work but gives a type match error:
type Foo[T] = object
x: T
proc foo(x: Foo[int | char]) = echo x
foo(Foo[int](x: 123))
(6, 4) Error: type mismatch
Expression: foo(Foo[int](x: 123))
[1] Foo[int](x: 123): Foo[system.int]
Expected one of (first mismatch at [position]):
[1] proc foo(x: Foo[int | char])
Maybe we could always treat Foo[int | char]
, proc (x: int | char)
etc as invalid?
Description
Probably asking the compiler to use a generic as a callback is understandably stressing the compiler out a bit, and maybe it is simply more than the language is capable of, but having the compiler crash is probably not the most informative way of telling the user he should not be trying to do it.
Nim Version
Nim Compiler Version 2.0.0 [Linux: amd64] Compiled at 2023-08-01 Copyright (c) 2006-2023 by Andreas Rumpf
git hash: a488067a4130f029000be4550a0fb1b39e0e9e7c active boot switches: -d:release
Current Output
No response
Expected Output
No response
Possible Solution
No response
Additional Information
No response