[PATCH 0/1] MR10317: vbscript: Allow Not operator as operand of comparison expressions.
The Not operator was only reachable from the NotExpression grammar rule, which sat above EqualityExpression in the precedence chain. This meant expressions like "a <> Not b" caused a syntax error because the right-hand side of a comparison could not contain Not. Adding Not as a unary operator in SignExpression (alongside unary minus and plus) allows it to be used within comparison operands. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55093 -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10317
From: Francis De Brabandere <francisdb@gmail.com> The Not operator was only reachable from the NotExpression grammar rule, which sat above EqualityExpression in the precedence chain. This meant expressions like "a <> Not b" caused a syntax error because the right-hand side of a comparison could not contain Not. Adding Not as a unary operator in SignExpression (alongside unary minus and plus) allows it to be used within comparison operands. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55093 --- dlls/vbscript/parser.y | 1 + dlls/vbscript/tests/lang.vbs | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 20c30eed681..ea562376be8 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -425,6 +425,7 @@ SignExpression : UnaryExpression { $$ = $1; } | '-' SignExpression { $$ = new_unary_expression(ctx, EXPR_NEG, $2); CHECK_ERROR; } | '+' SignExpression { $$ = $2; } + | tNOT SignExpression { $$ = new_unary_expression(ctx, EXPR_NOT, $2); CHECK_ERROR; } UnaryExpression : LiteralExpression { $$ = $1; } diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 0025bfeddcf..4f9151b0619 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -92,6 +92,14 @@ Call ok(not(false = true = ""), "false = true = """" is true") Call ok(not (false = false <> false = false), "false = false <> false = false is true") Call ok(not ("" <> false = false), """"" <> false = false is true") +Call ok(true <> Not true, "true <> Not true should be true") +Call ok(false <> Not false, "false <> Not false should be true") +Call ok(true = Not false, "true = Not false should be true") +Call ok(Not false = true, "Not false = true should be true") +Call ok(Not true <> true, "Not true <> true should be true") +Call ok(Not true = false, "Not true = false should be true") +Call ok(Not 1 > 2, "Not 1 > 2 should be true") + Call ok(getVT(false) = "VT_BOOL", "getVT(false) is not VT_BOOL") Call ok(getVT(true) = "VT_BOOL", "getVT(true) is not VT_BOOL") Call ok(getVT("") = "VT_BSTR", "getVT("""") is not VT_BSTR") @@ -2289,4 +2297,5 @@ f1 not 1 = 0 arr (0) = 2 xor -2 + reportSuccess() -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10317
This introduces a number of educe/reduce conflicts bison warnings, probably due to conflict with the existing `tNOT` handling. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10317#note_132173
participants (3)
-
Francis De Brabandere -
Francis De Brabandere (@francisdb) -
Jacek Caban (@jacek)