I have this code where I'm using range to make illegal values unrepresentable:
type Bitflags*[Nb: static int] = object
flags: array[(Nb + 31) div 32, uint32]
func incl*[Nb: static int](self: var Bitflags[Nb], flagIdx: range[0 .. (Nb - 1)]) =
discard
var bf = Bitflags[60]()
#bf.incl(100) # Error: conversion from int literal(100) to range 0..59(int) is invalid
assert not compiles(bf.incl(100)) My goal is to have a unit test confirm this should not compile (I've used assert here as a stand-in for a unittest check).
My questions:
Lastly, I'm only seeing Nim versions 1.X.X on the playground. Anybody else seeing this?