diff options
-rw-r--r-- | jim.c | 6 | ||||
-rw-r--r-- | regtest.tcl | 5 |
2 files changed, 10 insertions, 1 deletions
@@ -8791,7 +8791,11 @@ static int ExprCheckCorrectness(Jim_Interp *interp, Jim_Obj *exprObjPtr, ExprByt ternary++; } else if (t->type == JIM_EXPROP_COLON || t->type == JIM_EXPROP_COLON_LEFT) { - ternary--; + if (--ternary < 0) { + /* got : without preceding ? */ + stacklen = 1; + break; + } } /* All operations and operands add one to the stack */ diff --git a/regtest.tcl b/regtest.tcl index d84e72c..8bc6962 100644 --- a/regtest.tcl +++ b/regtest.tcl @@ -272,6 +272,11 @@ puts "TEST 35 PASSED" catch {/ 1 0} puts "TEST 36 PASSED" +# REGTEST 37 +# ternary operator order +catch {expr {1 : 2 ? 3}} +puts "TEST 37 PASSED" + # TAKE THE FOLLOWING puts AS LAST LINE puts "--- ALL TESTS PASSED ---" |