You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
compiler: assert (a & b) == c parses as assert(a & b) followed by == c #5593
if (!(A & B)) @panic("assertion failed") ==A;
if (!(A<B)) __t27_assert_fail("...", .{ A, B }) and (B>A);
The AST is ExprBinary(==, ExprCall assert(A & B), A): the parenthesised operand became the call's argument, and the comparison took the call as its operand.
Typecheck reports ok. Only zig test notices, with "unreachable code" or "expected type 'bool', found 'u32'".
Cause
bootstrap/src/compiler.rs, the bare-assert path of statement parsing, requires self.peek.kind != TokenKind::LParen. So every assert ( takes the call path, even when the parenthesis only opens the first operand of a longer condition.
Scope in the corpus
13 lines in 8 specs have the shape assert (...) <binary op> .... Among them:
A t27 spec for the CLK_PERF / PHSR_PERFCLK segbits rows of openXC7/prjxray-db#30. It had to work around the bug with an is_subset(a, b) helper.
Proposed fix
Add a lookahead. When the token after the ) that matches assert ( is a binary operator on the same line, parse the bare form. assert(x); and assert(x, "msg") keep their AST.
Activity
blog: one regional clock, twelve pull requests, and a spec that found…
Deploy 42e97a5