From: Robert Wilhelm robert.wilhelm@gmx.net
https://bugs.winehq.org/show_bug.cgi?id=55502 --- dlls/vbscript/compile.c | 33 +++++++++++++++++---------------- dlls/vbscript/tests/lang.vbs | 6 ++++++ 2 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index f86ecfded91..d0bbe974054 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -425,6 +425,18 @@ static expression_t *lookup_const_decls(compile_ctx_t *ctx, const WCHAR *name, B return NULL; }
+static BOOL lookup_args_name(compile_ctx_t *ctx, const WCHAR *name) +{ + unsigned i; + + for(i = 0; i < ctx->func->arg_cnt; i++) { + if(!wcsicmp(ctx->func->args[i].name, name)) + return TRUE; + } + + return FALSE; +} + static HRESULT compile_args(compile_ctx_t *ctx, expression_t *args, unsigned *ret) { unsigned arg_cnt = 0; @@ -479,10 +491,11 @@ static HRESULT compile_member_expression(compile_ctx_t *ctx, member_expression_t if (expr->obj_expr) /* FIXME: we should probably have a dedicated opcode as well */ return compile_member_call_expression(ctx, expr, 0, TRUE);
- const_expr = lookup_const_decls(ctx, expr->identifier, TRUE); - if(const_expr) - return compile_expression(ctx, const_expr); - + if (!lookup_args_name(ctx, expr->identifier)) { + const_expr = lookup_const_decls(ctx, expr->identifier, TRUE); + if(const_expr) + return compile_expression(ctx, const_expr); + } return push_instr_bstr(ctx, OP_ident, expr->identifier); }
@@ -1116,18 +1129,6 @@ static BOOL lookup_dim_decls(compile_ctx_t *ctx, const WCHAR *name) return FALSE; }
-static BOOL lookup_args_name(compile_ctx_t *ctx, const WCHAR *name) -{ - unsigned i; - - for(i = 0; i < ctx->func->arg_cnt; i++) { - if(!wcsicmp(ctx->func->args[i].name, name)) - return TRUE; - } - - return FALSE; -} - static HRESULT compile_dim_statement(compile_ctx_t *ctx, dim_statement_t *stat) { dim_decl_t *dim_decl = stat->dim_decls; diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 55efdcb5a00..42069a0d436 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -967,6 +967,12 @@ x = false Call TestFuncArgVal(x) Call ok(not x, "x is true after TestFuncArgVal call?")
+const c10 = 10 +Sub TestParamvsConst(c10) + Call ok( c10 = 42, "precedence between const and parameter wrong!") +End Sub +Call TestParamvsConst(42) + Function TestFuncMultiArgs(a,b,c,d,e) Call ok(a=1, "a = " & a) Call ok(b=2, "b = " & b)
Jacek Caban (@jacek) commented about dlls/vbscript/compile.c:
if (expr->obj_expr) /* FIXME: we should probably have a dedicated opcode as well */ return compile_member_call_expression(ctx, expr, 0, TRUE);
- const_expr = lookup_const_decls(ctx, expr->identifier, TRUE);
- if(const_expr)
return compile_expression(ctx, const_expr);
- if (!lookup_args_name(ctx, expr->identifier)) {
Please don't use tab here. Also, while you're at it, we should check `lookup_dim_decls()` as well, see the [attached test](/uploads/dfd20e6064fdf258b2ad278d21b79c2e/test.diff).