-
- Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Closed
Copy link
Labels
Description
If you perform an operation on 2 sets with the same base type but one being a range type of that type, you get a codegen error instead of a type mismatch.
Example
var x: set[range[1u8..5u8]] x.incl(1) x.incl(3) x.incl(5) if {1u8, 5} < x: echo "successful" discard {1u8, 3, 5} + xCurrent Output
/usercode/nimcache/@min.nim.c: In function 'NimMainModule': /usercode/nimcache/@min.nim.c:180:50: error: cast specifies array type T4_ = ((TM__JXJjWlLylejo6nWONmO6cA_2[T3_] & ~ ((tySet_tyUInt8__k3HXouOuhqAKq0dx450lXQ) (x__EGWKGClUlppqAonIP2rgfg))[T3_]) == 0); ^ /usercode/nimcache/@min.nim.c:182:58: error: cast specifies array type if (T4_) T4_ = (nimCmpMem(TM__JXJjWlLylejo6nWONmO6cA_2, ((tySet_tyUInt8__k3HXouOuhqAKq0dx450lXQ) (x__EGWKGClUlppqAonIP2rgfg)), 32) != 0); ^ /usercode/nimcache/@min.nim.c:191:51: error: cast specifies array type T8_[T7_] = TM__JXJjWlLylejo6nWONmO6cA_5[T7_] | ((tySet_tyUInt8__k3HXouOuhqAKq0dx450lXQ) (x__EGWKGClUlppqAonIP2rgfg))[T7_]; Expected Output
type mismatch, got set[range[1u8..5u8]] but expected set[uint8] etc
Additional Information
- Very slightly related: C Error on invalid uint -> set cast #3540
$ nim -v Nim Compiler Version 1.2.6