Open zeitbit opened 3 years ago
I couldnt resist trying the following, and it might be related to the issue. The types of a forward declared procedure seems to be unresolved until the implementation is specified meaning the return type is the typeclass you specified causing this error.
proc fn(): int32 | int64
static: assert typeof(fn()) is (int64 or int32)
proc fn(): int32 | int64 = 1
static: assert typeof(fn()) is int
Oh this is interesting. The timing for this is mostly dictated in semProcAux and the generic call I think that's in semgnrcs.nim. With the type class in the return that should make this implicitly generic. If you want to take a stab at it I would poke at semProcAux as a start. It'll be a good test to see if the reworking of the code helped clarify things.
(There is a slim chance I can look at it this weekend)
Hello,
This works OK:
But using a forward declaration fails, "Error: invalid type: 'int32 or int64' for var":
Specifying the type (int32 or int) produces this error: "Error: type mismatch: got 'int32 or int64' for 'fn()' but expected 'int32'"
And with int64 the exception: "Error: unhandled exception: ccgtypes.nim(198, 17)
false
mapType: tyOr [AssertionDefect]"Nim Compiler Version 1.5.1 [Windows: amd64] Compiled at 2021-04-03