fixes #25252; Unexpected ambiguous call with fields over object with default fields (#25256)

fixes #25252

(cherry picked from commit d54b5f3ae1)
This commit is contained in:
ringabout
2025-11-04 20:08:07 +08:00
committed by narimiran
parent 7f6c0afa59
commit 61e98e9bf1
3 changed files with 19 additions and 5 deletions

View File

@@ -375,7 +375,7 @@ template main {.dirty.} =
type
Color = enum
Red, Blue, Yellow
type
ObjectVarint3 = object
case kind: Color = Blue
@@ -663,7 +663,7 @@ template main {.dirty.} =
when not(T is void):
v.vResultPrivate
type R = Result[int, string]
proc testAssignResult() =
@@ -811,3 +811,17 @@ template main {.dirty.} =
static: main()
main()
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())