c3c icon indicating copy to clipboard operation
c3c copied to clipboard

Optional does not propagate for bitstruct operators

Open cbuttner opened this issue 2 weeks ago • 1 comments

bitstruct Foo : int {
  bool a;
}

fn void main() {
  Foo? a, b;

  Foo? c = a | b;
  //       ^^^^^
  // Error: | is not defined in the expression 'Foo?' | 'Foo?'.
  Foo? d = a & b;
  //       ^^^^^
  // Error: & is not defined in the expression 'Foo?' & 'Foo?'.
  Foo? e = a ^ b;
  //       ^^^^^
  // Error: ^ is not defined in the expression 'Foo?' ^ 'Foo?'.
}

cbuttner avatar Dec 05 '25 14:12 cbuttner

This should work properly now. There was further problems when hiding bools and bitstructs behind typedefs as well. It works for the test cases I've added, but maybe there is more. Note that all three bitops are handled in the same code path, so if one works, all the others work as well.

lerno avatar Dec 05 '25 23:12 lerno