mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 12:07:51 +00:00
16 lines
297 B
Nim
16 lines
297 B
Nim
type
|
|
MyInt = object
|
|
bitWidth: int
|
|
|
|
template toRealType*(t: MyInt): typedesc =
|
|
when t.bitWidth == 32: int32
|
|
elif t.bitWidth == 64: int64
|
|
else: {.error.}
|
|
|
|
proc doFail(T: typedesc): T = default(T)
|
|
|
|
proc test =
|
|
const myInt = MyInt(bitWidth:32)
|
|
discard doFail(toRealType(myInt))
|
|
|
|
test() |