Closed pczarn closed 4 weeks ago
Hmm I wonder how rust parses {} || a;
as two statements rather than a Binop(Or, Block, Var("a"))
Changed the title after finding a more troubling cases:
fn foo() -> fn(u32) -> u32 {
if bar == baz {
// something
}
|arg: u32| arg + 123
}
This was already fixed in the past where a block expression was also eventually parsed as a block statement. (this works fine in master)
Aim
Tried to parse the following Noir code found by the parser-fuzzer:
As well as this valid Rust code in Rust:
Expected Behavior
Expected a successful parse.
Bug
The parser attempts to parse lambda
|
as operators in an expression{} | ... | expr
.The parse error is, expected binary operator, found colon:
ParserError { expected_tokens: {}, expected_labels: {BinaryOperator}, found: Colon, reason: None, span: Span(Span { start: ByteIndex(70), end: ByteIndex(71) }) }]
This means making a formal grammar for Noir that follows the parser is hard.
To Reproduce
Try to parse code with a block followed by a lambda expression.
Installation Method
Compiled from source.
Additional Context
Found by the parser-fuzzer tool.
Would you like to submit a PR for this Issue?
No