You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a generic type is defined as a routine invocation, it—surprisingly—matters whether the call has parentheses or not.
templatehelper(_: untyped): untyped=inttype# Each of them should always be `int`.GenA[T] = helper intGenB[T] =helper(int)
GenC[T] =helperhelper(int)
block:
templatehelper(_: untyped): untyped=floattype
A =GenA[int]
B =GenB[int]
C =GenC[int]
assert A isint# OK.assert B isint# Fails; it is `float`!assert C isint# OK.
Nim Version
Nim Compiler Version 2.0.2 [Linux: amd64]
Compiled at 2023-12-15
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: c4c44d1
active boot switches: -d:release
Current Output
Error: unhandled exception: /home/nickolas/c/asynciters/a.nim(19, 3) `B is int` [AssertionDefect]
Expected Output
No response
Possible Solution
No response
Additional Information
It seems to be irrelevant whether helper has untyped, typed, or type parameter / return value. As I see, the only thing that matters is whether the command-call syntax is used for the top-level call.
This bug has been existing since at least 0.19—that’s the oldest Nim I have on my system to check.
The text was updated successfully, but these errors were encountered:
Should be n.kind in nkCallKinds, but apparently this was intentional at the time this line was added. Maybe things are different now though. Worst case we just whitelist nkCommand too.
metagn
added a commit
to metagn/Nim
that referenced
this issue
Mar 15, 2024
Description
When a generic type is defined as a routine invocation, it—surprisingly—matters whether the call has parentheses or not.
Nim Version
Nim Compiler Version 2.0.2 [Linux: amd64]
Compiled at 2023-12-15
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: c4c44d1
active boot switches: -d:release
Current Output
Expected Output
No response
Possible Solution
No response
Additional Information
It seems to be irrelevant whether
helper
hasuntyped
,typed
, ortype
parameter / return value. As I see, the only thing that matters is whether the command-call syntax is used for the top-level call.This bug has been existing since at least 0.19—that’s the oldest Nim I have on my system to check.
The text was updated successfully, but these errors were encountered: