> template/generic instantiation of + from here
This means + is generic and the real operation/error is elsewhere.
Error: type mismatch: got <HashSet[cc.Constraint]>
but expected one of:
iterator items[T](a: seq[T]): T
first type mismatch at position: 1
required type for a: seq[T]
.....
Run
Means something error happened to make the compiler couldn't expand to items
iterator.
You need to expand it by yourself to find out.
proc addConstraints*[T, V](constraints: var Constraints[T, V], choice: T,
consts: seq[V]) =
for c in consts:
constraints[choice].incl c
Run
This will lead to interesting error yet it's crucial that, constraints has no
key of i:1 (of course, it the `choice` arg supplied). If you know the actual
error, then you just modify your code to
proc addConstraints*[T, V](constraints: var Constraints[T, V], choice: T,
consts: seq[V]) =
let hasKey = choice in constraints:
for c in consts:
if hasKey:
constraints[choice].incl c
else:
constraints[choice] = @[c].toHashSet()
Run
That way you avoid the KeyError that thrown out.