Browse Source

[parser] fix ?? precedence

closes #11144
Simon Krajewski 2 years ago
parent
commit
e90e32d9d0
2 changed files with 10 additions and 2 deletions
  1. 2 2
      src/syntax/parser.ml
  2. 8 0
      tests/unit/src/unit/issues/Issue11144.hx

+ 2 - 2
src/syntax/parser.ml

@@ -270,8 +270,8 @@ let precedence op =
 	| OpEq | OpNotEq | OpGt | OpLt | OpGte | OpLte -> 6, left
 	| OpEq | OpNotEq | OpGt | OpLt | OpGte | OpLte -> 6, left
 	| OpInterval -> 7, left
 	| OpInterval -> 7, left
 	| OpBoolAnd -> 8, left
 	| OpBoolAnd -> 8, left
-	| OpBoolOr -> 9, left
-	| OpArrow | OpNullCoal -> 10, right
+	| OpBoolOr | OpNullCoal -> 9, left
+	| OpArrow -> 10, right
 	| OpAssign | OpAssignOp _ -> 11, right
 	| OpAssign | OpAssignOp _ -> 11, right
 
 
 let is_higher_than_ternary = function
 let is_higher_than_ternary = function

+ 8 - 0
tests/unit/src/unit/issues/Issue11144.hx

@@ -0,0 +1,8 @@
+package unit.issues;
+
+class Issue11144 extends Test {
+	function test() {
+		t(false ?? false || true); // false
+		t((false ?? false) || true); // true
+	}
+}