git.delta.rocks / jrsonnet / refs/commits / 15dca76ce252

difftreelog

refactor(ir) drop Parened expr

ksrxlvqlYaroslav Bolyukin2026-03-19parent: #7681558.patch.diff
in: master

4 files changed

modifiedcrates/jrsonnet-evaluator/src/async_import.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/async_import.rs
+++ b/crates/jrsonnet-evaluator/src/async_import.rs
@@ -211,7 +211,7 @@
 				find_imports(expr, out);
 			}
 		}
-		Expr::Parened(expr) | Expr::UnaryOp(_, expr) | Expr::ErrorStmt(expr) => {
+		Expr::UnaryOp(_, expr) | Expr::ErrorStmt(expr) => {
 			find_imports(expr, out);
 		}
 	}
modifiedcrates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/evaluate/mod.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/mod.rs
@@ -53,7 +53,6 @@
 			| Expr::Num(_)
 			| Expr::Literal(LiteralType::False | LiteralType::True | LiteralType::Null) => true,
 			Expr::Arr(a) => a.iter().all(is_trivial),
-			Expr::Parened(e) => is_trivial(e),
 			_ => false,
 		}
 	}
@@ -76,7 +75,6 @@
 					.collect(),
 			))
 		}
-		Expr::Parened(e) => evaluate_trivial(e)?,
 		_ => return None,
 	})
 }
@@ -414,7 +412,6 @@
 		Literal(LiteralType::True) => Val::Bool(true),
 		Literal(LiteralType::False) => Val::Bool(false),
 		Literal(LiteralType::Null) => Val::Null,
-		Parened(e) => evaluate(ctx, e)?,
 		Str(v) => Val::string(v.clone()),
 		Num(v) => Val::try_num(*v)?,
 		// I have tried to remove special behavior from super by implementing standalone-super
modifiedcrates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth
--- a/crates/jrsonnet-parser/src/expr.rs
+++ b/crates/jrsonnet-parser/src/expr.rs
@@ -336,9 +336,6 @@
 	/// Object extension: var1 {b: 2}
 	ObjExtend(LocExpr, ObjBody),
 
-	/// (obj)
-	Parened(LocExpr),
-
 	/// -2
 	UnaryOp(UnaryOpType, LocExpr),
 	/// 2 - 2
modifiedcrates/jrsonnet-parser/src/lib.rsdiffbeforeafterboth
313 use UnaryOpType::*;313 use UnaryOpType::*;
314 rule expr(s: &ParserSettings) -> LocExpr314 rule expr(s: &ParserSettings) -> LocExpr
315 = precedence! {315 = precedence! {
316 "(" _ e:expr(s) _ ")" {e}
316 start:position!() v:@ end:position!() { LocExpr::new(v, Span(s.source.clone(), start as u32, end as u32)) }317 start:position!() v:@ end:position!() { LocExpr::new(v, Span(s.source.clone(), start as u32, end as u32)) }
317 --318 --
318 a:(@) _ binop(<"||">) _ b:@ {expr_bin!(a Or b)}319 a:(@) _ binop(<"||">) _ b:@ {expr_bin!(a Or b)}
359 a:(@) _ "{" _ body:objinside(s) _ "}" {Expr::ObjExtend(a, body)}360 a:(@) _ "{" _ body:objinside(s) _ "}" {Expr::ObjExtend(a, body)}
360 --361 --
361 e:expr_basic(s) {e}362 e:expr_basic(s) {e}
362 "(" _ e:expr(s) _ ")" {Expr::Parened(e)}
363 }363 }
364 pub rule index_part(s: &ParserSettings) -> IndexPart364 pub rule index_part(s: &ParserSettings) -> IndexPart
365 = n:("?" _ ensure_null_coaelse())? "." _ value:id_loc(s) {IndexPart {365 = n:("?" _ ensure_null_coaelse())? "." _ value:id_loc(s) {IndexPart {
559 el!(Expr::Num(2.0), 0, 1),559 el!(Expr::Num(2.0), 0, 1),
560 Add,560 Add,
561 el!(561 el!(
562 Expr::Parened(el!(562 Expr::BinaryOp(
563 Expr::BinaryOp(
564 el!(Expr::Num(2.0), 3, 4),563 el!(Expr::Num(2.0), 3, 4),
565 Add,564 Add,
566 el!(565 el!(
575 ),574 ),
576 3,575 3,
577 8576 8
578 )),
579 2,
580 9
581 ),577 ),
582 ),578 ),
583 0,579 0,