c3c icon indicating copy to clipboard operation
c3c copied to clipboard

Compiler assert: Casting bitstruct to short/char

Open cbuttner opened this issue 6 months ago • 1 comments

bitstruct Foo : ushort {
  bool bar;
}

fn void main() {
  ushort foo = (ushort)((Foo) {.bar}) & 1;
}
⚠️ The compiler encountered an unexpected error: "Violated assert: expr->const_expr.const_kind == CONST_INTEGER || expr->const_expr.const_kind == CONST_ENUM".

cbuttner avatar Jun 23 '25 11:06 cbuttner

This should be fixed now, please try it out.

lerno avatar Jun 23 '25 12:06 lerno

Is this working?

lerno avatar Jul 07 '25 10:07 lerno

I tried this and it asserts on 0.7.2 but is fixed in 0.7.3, and seems to works like you'd expect.

BWindey avatar Jul 07 '25 10:07 BWindey