I thought it could be easly done via concept like this:
type AnyOfSize[S: static int] = concept type T
sizeof(T) == S
proc p(a: AnyOfSize[4]) =
echo a
p(0'i16) # <-- error
Run
However this code also works... maybe it's a bug?
type AnyOfSize[S: static int] = concept type T
sizeof(T) == S
proc p(a: AnyOfSize[4]) =
echo a
p(0'u32) # <-- works as expected
p(0'i16) # <-- why is this ok...?
Run
