[template-glib] expr: use left associativity for compare



commit 377c3ec7ad7d7704f8ea66c274bf8df11d68a7fd
Author: Christian Hergert <chergert redhat com>
Date:   Fri May 6 11:01:17 2022 -0700

    expr: use left associativity for compare
    
    Its nice and all to force extraneous (), but its also really annoying.

 src/tmpl-expr-parser.y | 2 +-
 tests/test1.script     | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/src/tmpl-expr-parser.y b/src/tmpl-expr-parser.y
index 8ca3dca..06a72d7 100644
--- a/src/tmpl-expr-parser.y
+++ b/src/tmpl-expr-parser.y
@@ -125,7 +125,7 @@ add_to_list (TmplExpr *stmt,
 %token IF THEN ELSE WHILE DO FUNC
 %token NOP
 
-%nonassoc <cmp> CMP
+%left <cmp> CMP
 %right '='
 %left '+' '-'
 %left '*' '/'
diff --git a/tests/test1.script b/tests/test1.script
index 802fdf5..cd6c7b9 100644
--- a/tests/test1.script
+++ b/tests/test1.script
@@ -94,4 +94,11 @@ multiline = (1 + \
              3)
 assert(multiline == 6)
 
+# test left associativity
+val = true && true || false
+assert(val == true)
+# if only we had compiler warnings
+val = true && false || true
+assert(val == true)
+
 1234;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]