-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Nim Version
Nim Compiler Version 2.3.1 [Windows: amd64]
Compiled at 2025-11-01
Copyright (c) 2006-2025 by Andreas Rumpf
git hash: 5079074
active boot switches: -d:release
Description
type
Thing = object
a: int = 100 # this is fine
b = 100 # this is not
proc overloaded[T: SomeSignedInt](x: T) = discard
proc overloaded[T: SomeUnsignedInt](x: T) = discard
proc overloaded[T: object](x: T) =
for val in fields(x):
var v: typeof(val)
overloaded(v)
overloaded(Thing())Current Output
/repro.nim(13, 11) template/generic instantiation of `overloaded` from here
/repro.nim(11, 15) Error: ambiguous call; both repro.overloaded(x: T: SomeSignedInt) [proc declared in /repro.nim(6, 6)] and repro.overloaded(x: T: SomeUnsignedInt) [proc declared in /repro.nim(7, 6)] match for: (int literal(100))
Expected Output
Known Workarounds
- Change
b = 100tob: int = 100. - Change
var v: typeof(val)tovar v = default typeof(val)
Additional Information
- Requires all three
overloadedto be generic.
Metadata
Metadata
Assignees
Labels
No labels