[PATCH v2 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 -- v2: vbscript: Allow Not operator as operand of comparison expressions. 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 | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 42df9afaf8f..5e19251e525 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -441,6 +441,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 4374d7b1f25..936b8df3537 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") -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10317
participants (2)
-
Francis De Brabandere -
Francis De Brabandere (@francisdb)