-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Nim Version
Builds:
Nim Compiler Version 2.0.14 [Linux: amd64]
Compiled at 2025-03-15
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: bf4de6a394e040d9810cba8c69fb2829ff04dcc6
active boot switches: -d:release
Nim Compiler Version 2.0.15 [Linux: amd64]
Compiled at 2025-03-15
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: d01002d8f8cf2c12e67e4ddae3e5990a7d92e753
active boot switches: -d:release
Does not build:
Nim Compiler Version 2.2.3 [Linux: amd64]
Compiled at 2025-03-15
Copyright (c) 2006-2025 by Andreas Rumpf
git hash: 44c1b2a6df6bcf47188b84dcdaad704685f72904
active boot switches: -d:release
Nim Compiler Version 2.3.1 [Linux: amd64]
Compiled at 2025-03-15
Copyright (c) 2006-2025 by Andreas Rumpf
git hash: fb93295344b78d2d45c81bc78bdba8526a893a09
active boot switches: -d:release
Description
k.nim:
import ./e
import ./w
proc r(_: int|int) = discard J()
r(0)e.nim:
type J* = objectw.nim:
type V* = enum
JNotably, this isn't truly ambiguous: if one tries to actually use discard w.J() to resolve it to that option, one gets:
/tmp/k.nim(5, 2) template/generic instantiation of `r` from here
/tmp/k.nim(4, 33) Error: attempting to call routine: 'J'
found 'J' [enumField declared in /tmp/w.nim(2, 3)]
because indeed it isn't a routine. As https://nim-lang.org/docs/manual.html#types-enumeration-types points out:
Enum value names are overloadable, much like routines. If both of the enums
TandUhave a member namedfoo, then the identifierfoocorresponds to a choice betweenT.fooandU.foo. During overload resolution, the correct type offoois decided from the context. If the type offoois ambiguous, a static error will be produced.
But the context here requires a routine, i.e.
a symbol of kind:
proc,func,method,iterator,macro,template,converter
as it figures out with the static errorError: attempting to call routine.
So no actual ambiguity exists here.
Current Output
/tmp/k.nim(5, 2) template/generic instantiation of `r` from here
/tmp/k.nim(4, 31) Error: attempting to call routine: 'J'
found e.J [type declared in /tmp/e.nim(1, 6)]
found 'J' [enumField declared in /tmp/w.nim(2, 3)]
Expected Output
Known Workarounds
No response
Additional Information
No response