Consider this code:
var x: 0..15 = 12
var s: set[0..15] = {12}
The first line defining x works fine. The second line defining s fails with this error:
/usercode/in.nim(1, 21) Error: type mismatch: got <set[range 0..65535(int)]> but expected 'set[range 0..15(int)]'
After some experimentation it seems like a set literal with bare numeric literals inside is always interpreted as a set[range 0..65535(int)] unless there's some other variable in there to force the typing. ex:
var x: 0..15 = 11
var s: set[0..15] = {x, 12}
works.
Is this a bug/oversight in Nim? Is there a way to specify the type on a set literal? Is there a way to create a range number constant? (apart from range[0..15](12) which is quite ugly.)
How about something like this:
type
MyRange = range[0'u8 .. 15'u8]
var s = {12.MyRange}