[PATCH v2 0/1] MR2142: vbscript: fix compile when colon follows Else on new line
I ran into a script where someone placed a `:` on a new line after an `Else` but before another statement: ``` Else : VelCoef = LinearEnvelope(BallPos, VelocityIn, VelocityOut) if Enabled then aBall.Velx = aBall.Velx*VelCoef if Enabled then aBall.Vely = aBall.Vely*VelCoef end if ``` I confirmed that this is allowed and works. I've updated the grammar, and replaced `NL` with `StSep_opt` as it seems to cover all the bases. Fixes: https://bugs.winehq.org/show_bug.cgi?id=54234 -- v2: vbscript: fix compile when colon follows Else on new line https://gitlab.winehq.org/wine/wine/-/merge_requests/2142
From: Jason Millard <jsm174(a)gmail.com> --- dlls/vbscript/parser.y | 3 +-- dlls/vbscript/tests/lang.vbs | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 382504a3d5a..03415dc2b1c 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -319,8 +319,7 @@ ElseIf Else_opt : /* empty */ { $$ = NULL; } - | tELSE tNL StatementsNl_opt { $$ = $3; } - | tELSE StatementsNl_opt { $$ = $2; } + | tELSE StSep_opt StatementsNl_opt { $$ = $3; } CaseClausules : /* empty */ { $$ = NULL; } diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 3a67cd09dff..1707cc9a92b 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -298,6 +298,15 @@ Else x = true End If Call ok(x, "else not called?") +' Else with colon before statement following newline +x = false +If false Then + Call ok(false, "inside if false") +Else +: x = true +End If +Call ok(x, "else not called?") + x = false If false Then Call ok(false, "inside if false") -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/2142
This merge request was approved by Jacek Caban. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2142
participants (3)
-
Jacek Caban (@jacek) -
Jason Millard -
Jason Millard (@jsm174)