diff --git a/src/Framework/Framework/Compilation/Parser/Binding/Parser/BindingParser.cs b/src/Framework/Framework/Compilation/Parser/Binding/Parser/BindingParser.cs index 2b9ec0f0a6..73db32e76a 100644 --- a/src/Framework/Framework/Compilation/Parser/Binding/Parser/BindingParser.cs +++ b/src/Framework/Framework/Compilation/Parser/Binding/Parser/BindingParser.cs @@ -313,7 +313,7 @@ private BindingParserNode ReadAndAlsoExpression() while (Peek() is BindingToken operatorToken && operatorToken.Type == BindingTokenType.AndAlsoOperator) { Read(); - var second = ReadOrElseExpression(); + var second = ReadOrExpression(); first = CreateNode(new BinaryOperatorBindingParserNode(first, second, BindingTokenType.AndAlsoOperator), startIndex); } return first; diff --git a/src/Tests/Binding/BindingCompilationTests.cs b/src/Tests/Binding/BindingCompilationTests.cs index 48c3bc9e0d..626f2f7d3a 100755 --- a/src/Tests/Binding/BindingCompilationTests.cs +++ b/src/Tests/Binding/BindingCompilationTests.cs @@ -1064,6 +1064,14 @@ public void BindingCompiler_Errors_AssigningToType() StringAssert.Contains(ex.Message, "Expression '123' cannot be assigned into 'System.String'."); } + [TestMethod] + public void BindingCompiler_LogicalOperatorPrecedence() + { + Assert.AreEqual(true, ExecuteBinding("(false && true) || (true && true)", new TestViewModel())); + Assert.AreEqual(true, ExecuteBinding("false && true || true && true", new TestViewModel())); + Assert.AreEqual(true, ExecuteBinding("true && true || true && false", new TestViewModel())); + } + [TestMethod] public void BindingCompiler_ExclusiveOrOperator() { diff --git a/src/Tests/Binding/JavascriptCompilationTests.cs b/src/Tests/Binding/JavascriptCompilationTests.cs index 81de562a92..b458be74ca 100644 --- a/src/Tests/Binding/JavascriptCompilationTests.cs +++ b/src/Tests/Binding/JavascriptCompilationTests.cs @@ -461,11 +461,18 @@ public void JsTranslator_IntegerArithmetic() Assert.AreEqual("(IntProp()/2|0)+((IntProp()+1)/(IntProp()-1)|0)", result); } + [TestMethod] + public void JsTranslator_BooleanOperatorPrecedence() + { + var result = CompileBinding("IntProp > 0 && IntProp > 1 || IntProp > 2 && IntProp > 3", new [] { typeof(TestViewModel)}); + Assert.AreEqual("IntProp()>0&&IntProp()>1||IntProp()>2&&IntProp()>3", result); + } + [TestMethod] public void JsTranslator_ArrayIndexer() { var result = CompileBinding("LongArray[1] == 3 && VmArray[0].MyProperty == 1 && VmArray.Length > 1", new [] { typeof(TestViewModel)}); - Assert.AreEqual("LongArray()[1]()==3&&(VmArray()[0]().MyProperty()==1&&VmArray().length>1)", result); + Assert.AreEqual("LongArray()[1]()==3&&VmArray()[0]().MyProperty()==1&&VmArray().length>1", result); } [TestMethod]