The following two examples fail to compile, but work fine in real vbscript:
``` Dim x x = 8
if x = 9 Then Wscript.Echo "HERE1" elseif x = 8 then Wscript.Echo "HERE2" else Wscript.Echo "HERE3" end if ```
``` Dim x x = 8
if x = 9 Then Wscript.Echo "HERE1" elseif x = 8 then : Wscript.Echo "HERE2" else Wscript.Echo "HERE3" end if ```
This was fixed similar using the same approach as https://gitlab.winehq.org/wine/wine/-/merge_requests/2142
From: Jason Millard jsm174@gmail.com
--- dlls/vbscript/parser.y | 2 +- dlls/vbscript/tests/lang.vbs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 03415dc2b1c..9ae6c478bfa 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -314,7 +314,7 @@ ElseIfs | ElseIf ElseIfs { $1->next = $2; $$ = $1; }
ElseIf - : tELSEIF Expression tTHEN tNL StatementsNl_opt + : tELSEIF Expression tTHEN StSep_opt StatementsNl_opt { $$ = new_elseif_decl(ctx, @$, $2, $5); }
Else_opt diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 1707cc9a92b..ab97fdb66d0 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -337,6 +337,23 @@ ElseIf not False Then End If Call ok(x, "elseif not called?")
+' ElseIf with statement on same line +x = false +If false Then + Call ok(false, "inside if false") +ElseIf not False Then x = true +End If +Call ok(x, "elseif not called?") + +' ElseIf with statement following statement separator +x = false +If false Then + Call ok(false, "inside if false") +ElseIf not False Then +: x = true +End If +Call ok(x, "elseif not called?") + x = false if 1 then x = true Call ok(x, "if 1 not run?")
This merge request was approved by Jacek Caban.