[PATCH 0/1] MR10318: vbscript: Allow End If on the same line as the preceding statement.
Use BodyStatements instead of StatementsNl_opt for If, ElseIf, and Else blocks so the last statement before End If does not require a trailing newline, matching native behavior. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55196 -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10318
From: Francis De Brabandere <francisdb@gmail.com> Use BodyStatements instead of StatementsNl_opt for If, ElseIf, and Else blocks so the last statement before End If does not require a trailing newline, matching native behavior. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55196 --- dlls/vbscript/parser.y | 6 +++--- dlls/vbscript/tests/lang.vbs | 22 ++++++++++++++++++++++ dlls/vbscript/tests/run.c | 6 ------ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 20c30eed681..ed9ce1dfd24 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -306,7 +306,7 @@ Step_opt | tSTEP Expression { $$ = $2; } IfStatement - : tIF Expression tTHEN tNL StatementsNl_opt ElseIfs_opt Else_opt tEND tIF + : tIF Expression tTHEN tNL BodyStatements ElseIfs_opt Else_opt tEND tIF { $$ = new_if_statement(ctx, @$, $2, $5, $6, $7); CHECK_ERROR; } | tIF Expression tTHEN Statement EndIf_opt { $$ = new_if_statement(ctx, @$, $2, $4, NULL, NULL); CHECK_ERROR; } | tIF Expression tTHEN Statement tELSE Statement EndIf_opt @@ -325,12 +325,12 @@ ElseIfs | ElseIf ElseIfs { $1->next = $2; $$ = $1; } ElseIf - : tELSEIF Expression tTHEN StSep_opt StatementsNl_opt + : tELSEIF Expression tTHEN StSep_opt BodyStatements { $$ = new_elseif_decl(ctx, @$, $2, $5); } Else_opt : /* empty */ { $$ = NULL; } - | tELSE StSep_opt StatementsNl_opt { $$ = $3; } + | tELSE StSep_opt BodyStatements { $$ = $3; } CaseClausules : /* empty */ { $$ = NULL; } diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 0025bfeddcf..50458008e4f 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -359,6 +359,28 @@ ElseIf not False Then End If Call ok(x, "elseif not called?") +' End If on same line as last statement in Else block +x = false +If false Then + Call ok(false, "inside if false") +Else + x = true End If +Call ok(x, "trailing End If in Else block not handled") + +' End If on same line as last statement in If block +x = false +If true Then + x = true End If +Call ok(x, "trailing End If in If block not handled") + +' End If on same line as last statement in ElseIf block +x = false +If false Then + Call ok(false, "inside if false") +ElseIf not false Then + x = true End If +Call ok(x, "trailing End If in ElseIf block not handled") + x = false if 1 then x = true Call ok(x, "if 1 not run?") diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index 8aaafbedf54..08ae7704f54 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -2650,12 +2650,6 @@ static void test_parse_errors(void) } invalid_scripts[] = { - { - /* If...End If */ - L"If 0 > 1 Then\n" - " x = 0 End If\n", - 1, 10 - }, { /* While...End While */ L"While False\n" -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10318
@jacek can you confirm that `lang.vbs` is also run on Windows using `cscript` during integration tests? Asking because this removes a case in `invalid_scripts`, I guess those are not validated to fail compilation on Windows? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10318#note_132068
On Thu Mar 12 17:39:12 2026 +0000, Francis De Brabandere wrote:
@jacek can you confirm that `lang.vbs` is also run on Windows using `cscript` during integration tests? Asking because this removes a case in `invalid_scripts`, I guess those are not validated to fail compilation on Windows? never mind, it's proven in the tests :-)
This one requires more validation, will do some testing on windows. Set to draft. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10318#note_132070
On Thu Mar 12 17:39:12 2026 +0000, Francis De Brabandere wrote:
never mind, it's proven in the tests :-) This one requires more validation, will do some testing on windows. Set to draft. `lang.vbs` does not use cscript, it is ran by `dlls/vbscript/tests/run.c` (which also provides things like ok()). To run it manually, you may use something like `wine vbscript_test.exe run` or `make dlls/vbscript/tests/test` to run all vbscript tests. Running tests both on Windows and Linux is a part of CI.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10318#note_132096
participants (3)
-
Francis De Brabandere -
Francis De Brabandere (@francisdb) -
Jacek Caban (@jacek)