Nim Version
Nim Compiler Version 2.0.17 [Linux: amd64]
Compiled at 2025-09-12
Copyright (c) 2006-2023 by Andreas Rumpf
active boot switches: -d:release
Description
The overload won't work when ref object of RootObj is the first parameter, otherwise it works.
type Obj = ref object of RootObj
proc foo(s: Obj, x: SomeFloat) =
echo "SomeFloat"
template foo(s: Obj, x: auto) =
echo "auto"
foo(Obj(), 1.23)
proc bar[T: SomeFloat](s: Obj, x: T) =
echo "SomeFloat"
proc bar[T](s: Obj, x: T) =
echo "any"
bar(Obj(), 1.23)
# the following works
proc baz[T: SomeFloat](x: T, s: Obj) =
echo "SomeFloat"
proc baz[T](x: T, s: Obj) =
echo "any"
baz(1.23, Obj())
type Obj2 = ref object
proc quz[T: SomeFloat](s: Obj2, x: T) =
echo "SomeFloat"
proc quz[T](s: Obj2, x: T) =
echo "any"
quz(Obj2(), 1.23)
Current Output
auto
any
SomeFloat
SomeFloat
Expected Output
SomeFloat
SomeFloat
SomeFloat
SomeFloat
Known Workarounds
No response
Additional Information
works as expected in Nim 2.0.8, 2.2.4 and devel
the regression is present in 2.0.10 to 2.0.16 and version-2-0 branch (commit edeac84)