Skip to content

Generic function constrained to uint64 incorrectly has parameter with int type #25194

@tersec

Description

@tersec

Nim Version

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

git hash: f7145dd26efeeeb6eeae6fff649db244d81b212d
active boot switches: -d:release
Nim Compiler Version 2.2.5 [Linux: amd64]
Compiled at 2025-09-25
Copyright (c) 2006-2025 by Andreas Rumpf

git hash: 0a18975472557d9d5ec1312cd44ccaa178b7f06c
active boot switches: -d:release
Nim Compiler Version 2.3.1 [Linux: amd64]
Compiled at 2025-09-25
Copyright (c) 2006-2025 by Andreas Rumpf

git hash: 9f74712ec6ec346f8f1366c10f752d0a9aa85a70
active boot switches: -d:release

Description

proc w[T: uint](v: T) =
  static: doAssert not (v is int)
w(0)

Whether or not this should work at all, the static: doAssert not (v is int) firing contradicts the [T: uint].

Current Output

Error: unhandled exception: /tmp/d.nim(2, 11) `not (v is int)`  [AssertionDefect]

Expected Output

Assertion should not fire

Known Workarounds

No response

Additional Information

No response

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