Skip to content

Generic overload ambiguous call for int literal; Regression in 2.0/2.2/devel #25172

@nitely

Description

@nitely

Nim Version

Nim Compiler Version 2.3.1 [Linux: amd64]
Compiled at 2025-09-13
Copyright (c) 2006-2025 by Andreas Rumpf

git hash: ff9cae8
active boot switches: -d:release

Description

proc foo[T: int](x: T) =
  echo "int"
proc foo[T: uint](x: T) =
  echo "uint"

foo(0'u) # ok
foo(0'u8) # ok
foo(0'i8) # ok
foo(0.int)  # ok
foo(0)  # fails

Current Output

ambiguous call error

Expected Output

uint
uint
int
int
int

Known Workarounds

No response

Additional Information

Works in Nim 1.6.20 and 2.0.8, fails in 2.0.10 to 2.0.16, 2.2.0 to 2.2.4 and devel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions