From 281fc2ba8afa50eb14efd05a061744b6c6718a8a Mon Sep 17 00:00:00 2001 From: "Guillem L. Jara" <4lon3ly0@tutanota.com> Date: Fri, 15 May 2026 16:37:56 +0200 Subject: [PATCH] parser: fall back to prefix inc/dec on postfix error --- parser/src/pratt.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/parser/src/pratt.rs b/parser/src/pratt.rs index 9ce7b4f..48fb758 100644 --- a/parser/src/pratt.rs +++ b/parser/src/pratt.rs @@ -74,9 +74,16 @@ impl<'a, 'b> Pratt<'a, 'b> { if op.binding_power() < min_bp { break; } - lex.next(); - let place = Place::lower_from(lhs.take(), lex.span())?; - Expr::node(op.expr(place), self.parser.arena) + match Place::lower_from(lhs.take(), lex.span()) { + Ok(place) => { + lex.next(); + Expr::node(op.expr(place), self.parser.arena) + } + Err((lhs, _)) => Expr::node( + BinaryOperator::Concat.expr(lhs, self.parse_prefix(lex)?), + self.parser.arena, + ), + } } else if let Ok(op) = BinaryPlaceOperator::parse(next, &span) { // Places consume assignment operators with maximum precedence; // effectively ignoring the enclosing operator's precedence.