diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 89e290de5b7..327d97b1585 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -625,6 +625,7 @@ static HRESULT compile_dowhile_statement(compile_ctx_t *ctx, while_statement_t * { statement_ctx_t loop_ctx = {0}; unsigned start_addr; + vbsop_t jmp_op; HRESULT hres; start_addr = ctx->instr_cnt; @@ -636,11 +637,17 @@ static HRESULT compile_dowhile_statement(compile_ctx_t *ctx, while_statement_t * if(FAILED(hres)) return hres; - hres = compile_expression(ctx, stat->expr); - if(FAILED(hres)) - return hres; + if(stat->expr) { + hres = compile_expression(ctx, stat->expr); + if(FAILED(hres)) + return hres; - hres = push_instr_addr(ctx, stat->stat.type == STAT_DOUNTIL ? OP_jmp_false : OP_jmp_true, start_addr); + jmp_op = stat->stat.type == STAT_DOUNTIL ? OP_jmp_false : OP_jmp_true; + }else { + jmp_op = OP_jmp; + } + + hres = push_instr_addr(ctx, jmp_op, start_addr); if(FAILED(hres)) return hres; diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index d5a9934eedb..3f86b041f96 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -185,6 +185,7 @@ SimpleStatement | tDO tNL StatementsNl_opt tLOOP DoType Expression { $$ = new_while_statement(ctx, $5 ? STAT_DOWHILE : STAT_DOUNTIL, $6, $3); CHECK_ERROR; } + | tDO tNL StatementsNl_opt tLOOP { $$ = new_while_statement(ctx, STAT_DOWHILE, NULL, $3); CHECK_ERROR; } | FunctionDecl { $$ = new_function_statement(ctx, $1); CHECK_ERROR; } | tEXIT tDO { $$ = new_statement(ctx, STAT_EXITDO, 0); CHECK_ERROR; } | tEXIT tFOR { $$ = new_statement(ctx, STAT_EXITFOR, 0); CHECK_ERROR; } diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index fd93df62aab..76f4003cea1 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -345,6 +345,13 @@ do until false ok false, "exit do didn't work" loop +x = false +do + if x then exit do + x = true +loop +call ok(x, "x is false after do..loop?") + x = false y = false do