[PATCH 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 -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2142
From: Jason Millard <jsm174(a)gmail.com> --- dlls/vbscript/parser.y | 2 +- dlls/vbscript/tests/lang.vbs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 382504a3d5a..78509ca9707 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -319,7 +319,7 @@ ElseIf Else_opt : /* empty */ { $$ = NULL; } - | tELSE tNL StatementsNl_opt { $$ = $3; } + | tELSE StSep_opt StatementsNl_opt { $$ = $3; } | tELSE StatementsNl_opt { $$ = $2; } CaseClausules 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
Jacek Caban (@jacek) commented about dlls/vbscript/parser.y:
Else_opt : /* empty */ { $$ = NULL; } - | tELSE tNL StatementsNl_opt { $$ = $3; } + | tELSE StSep_opt StatementsNl_opt { $$ = $3; } | tELSE StatementsNl_opt { $$ = $2; }
This introduces a number of bison warnings. You may fix it by removing, now useless, `tELSE StatementsNl_opt` rule. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2142#note_23609
participants (3)
-
Jacek Caban (@jacek) -
Jason Millard -
Jason Millard (@jsm174)