-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Description
Nim Version
Nim Compiler Version 2.2.4 [Linux: amd64]
Compiled at 2025-04-22
Copyright (c) 2006-2025 by Andreas Rumpf
git hash: f7145dd
active boot switches: -d:release
Description
the code works in play.nim-lang.org with the latest version and also older versions, but not on my machine
import std/random
func mods[T: static Natural](a: int, b: type T): range[0 .. T-1] =
cast[type result](a mod b.int)
let n = rand 0 .. 100
case n.mods 4
of 3,2,1: echo "huh"
of 0 : echo "got you"Current Output
play.nim(7, 7) template/generic instantiation of `mods` from here
play.nim(3, 11) Error: cannot instantiate: 'T'
Expected Output
compiles successfully
Known Workarounds
No response
Additional Information
No response
Metadata
Metadata
Assignees
Labels
No labels