git.delta.rocks / jrsonnet / refs/commits / 42f993d5b82c

difftreelog

fix(rowan) unary plus

msnwnxvoYaroslav Bolyukin2026-05-08parent: #5b43fa8.patch.diff
in: master

5 files changed

modifiedcrates/jrsonnet-rowan-parser/jsonnet.ungramdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/jsonnet.ungram
+++ b/crates/jrsonnet-rowan-parser/jsonnet.ungram
@@ -131,7 +131,7 @@
 |   'ERROR_NO_OPERATOR!'
 
 UnaryOperator =
-    '-' | '!' | '~'
+    '-' | '!' | '~' | '+'
 
 SliceDescEnd=Expr
 SliceDescStep=Expr
modifiedcrates/jrsonnet-rowan-parser/src/generated/nodes.rsdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/generated/nodes.rs
+++ b/crates/jrsonnet-rowan-parser/src/generated/nodes.rs
@@ -977,6 +977,7 @@
 	Minus,
 	Not,
 	BitNot,
+	Plus,
 }
 
 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -2494,7 +2495,7 @@
 impl UnaryOperatorKind {
 	fn can_cast(kind: SyntaxKind) -> bool {
 		match kind {
-			MINUS | NOT | BIT_NOT => true,
+			MINUS | NOT | BIT_NOT | PLUS => true,
 			_ => false,
 		}
 	}
@@ -2503,6 +2504,7 @@
 			MINUS => Self::Minus,
 			NOT => Self::Not,
 			BIT_NOT => Self::BitNot,
+			PLUS => Self::Plus,
 			_ => return None,
 		};
 		Some(res)
modifiedcrates/jrsonnet-rowan-parser/src/precedence.rsdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/precedence.rs
+++ b/crates/jrsonnet-rowan-parser/src/precedence.rs
@@ -22,7 +22,7 @@
 impl UnaryOperatorKind {
 	pub fn binding_power(&self) -> ((), u8) {
 		match self {
-			Self::Minus | Self::Not | Self::BitNot => ((), 20),
+			Self::Minus | Self::Not | Self::BitNot | Self::Plus => ((), 20),
 		}
 	}
 }
modifiedcrates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__no_lhs.snapdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__no_lhs.snap
+++ b/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__no_lhs.snap
@@ -1,12 +1,13 @@
 ---
 source: crates/jrsonnet-rowan-parser/src/tests.rs
-expression: "+ 2\n"
+assertion_line: 60
+expression: "* 2\n"
 ---
 SOURCE_FILE@0..4
   EXPR@0..0
     ERROR_MISSING_TOKEN@0..0
   ERROR_CUSTOM@0..3
-    PLUS@0..1 "+"
+    MUL@0..1 "*"
     WHITESPACE@1..2 " "
     FLOAT@2..3 "2"
   WHITESPACE@3..4 "\n"
@@ -15,5 +16,5 @@
 LocatedSyntaxError { error: Custom { error: "unexpected tokens after end" }, range: 0..3 }
 ===
    · ╭── missing expression
-1  │ + 2
+1  │ * 2
    · ╰───── unexpected tokens after end
modifiedcrates/jrsonnet-rowan-parser/src/tests.rsdiffbeforeafterboth
84 no_rhs => r#"84 no_rhs => r#"
85 a +85 a +
86 "#86 "#
87 no_lhs => r#"87 no_lhs => r#"
88 + 288 * 2
89 "#89 "#
90 no_operator => "90 no_operator => "
91 2 291 2 2
92 "92 "