Skip to content

Codegen error when operating on sets of a type and of a range of the same type #15435

@metagn

Description

@metagn

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} + x

Current 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

$ nim -v Nim Compiler Version 1.2.6 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions