-
- Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
Description
a.nim
type Foo* = object Bar* = object func `$`*(x: Foo | Bar): string = "X"b.nim
import ./a type FooX = distinct Foo func `$`*(x: FooX): string = $a.Foo(x)Nim Version
% nim -v Nim Compiler Version 2.1.1 [MacOSX: amd64] Compiled at 2024-01-05 Copyright (c) 2006-2024 by Andreas Rumpf git hash: 3dee1a3e4c81448b67b75068fef06a121f320758 active boot switches: -d:release Current Output
Error: ambiguous call; both objectdollar.$(x: T: object) [proc declared in Nim/lib/std/objectdollar.nim(5, 6)] and a.$(x: Foo or Bar) [func declared in a.nim(5, 6)] match for: (Foo) $a.Foo(x) ^ Expected Output
Success Possible Solution
It works when a.nim defines two separate $ implementations for Foo and Bar. Only with Foo | Bar is broken.
Additional Information
OK on version-2-0 and version-1-6.