From: Francis De Brabandere <francisdb@gmail.com> The compiler tags each comparison operand at the source-AST level: a bare numeric literal (EXPR_INT / EXPR_DOUBLE / EXPR_DATE, parens transparent) sets a flag bit on the comparison opcode, and var_cmp dispatches on that flag so BSTR vs literal numeric goes through numeric coercion (error 13 on parse failure) while BSTR vs non-literal numeric uses string compare against CStr(numeric). VT_BOOL is handled in the same branch with hardcoded "True"/"False" since VarBstrFromBool yields "-1"/"0". Const references compile to an EXPR_MEMBER node, so they are correctly tagged non-literal even though the value is inlined at compile time. --- dlls/vbscript/compile.c | 49 ++++++++++++- dlls/vbscript/interp.c | 73 +++++++++++++++---- dlls/vbscript/tests/lang.vbs | 135 ++++++++++++++++++++--------------- dlls/vbscript/vbscript.h | 14 ++-- 4 files changed, 190 insertions(+), 81 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 16e661c98ff..99d218c93cb 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -204,6 +204,19 @@ static HRESULT push_instr_addr(compile_ctx_t *ctx, vbsop_t op, unsigned arg) return S_OK; } +static HRESULT push_instr_addr_uint(compile_ctx_t *ctx, vbsop_t op, unsigned arg1, unsigned arg2) +{ + unsigned ret; + + ret = push_instr(ctx, op); + if(!ret) + return E_OUTOFMEMORY; + + instr_ptr(ctx, ret)->arg1.uint = arg1; + instr_ptr(ctx, ret)->arg2.uint = arg2; + return S_OK; +} + static HRESULT push_instr_str(compile_ctx_t *ctx, vbsop_t op, const WCHAR *arg) { unsigned instr; @@ -590,6 +603,28 @@ static HRESULT compile_unary_expression(compile_ctx_t *ctx, unary_expression_t * return push_instr(ctx, op) ? S_OK : E_OUTOFMEMORY; } +/* Bare numeric literals at a comparison site take a different code path on + * Windows VBScript: BSTR vs literal numeric coerces to a number (error 13 on + * parse failure), while BSTR vs anything else (variable, arithmetic result, + * function return, Const, ...) uses string comparison. Detect "bare numeric + * literal" syntactically; parens are transparent, but a Const reference is an + * EXPR_MEMBER and thus correctly treated as non-literal even if its expansion + * is itself an EXPR_INT. */ +static BOOL is_literal_expr(expression_t *expr) +{ + while(expr->type == EXPR_BRACKETS) + expr = ((unary_expression_t*)expr)->subexpr; + return expr->type == EXPR_INT + || expr->type == EXPR_DOUBLE + || expr->type == EXPR_DATE; +} + +static BOOL is_compare_op(vbsop_t op) +{ + return op == OP_equal || op == OP_nequal || op == OP_gt + || op == OP_gteq || op == OP_lt || op == OP_lteq; +} + static HRESULT compile_binary_expression(compile_ctx_t *ctx, binary_expression_t *expr, vbsop_t op) { HRESULT hres; @@ -602,6 +637,12 @@ static HRESULT compile_binary_expression(compile_ctx_t *ctx, binary_expression_t if(FAILED(hres)) return hres; + if(is_compare_op(op)) { + unsigned flags = (is_literal_expr(expr->left) ? 1 : 0) + | (is_literal_expr(expr->right) ? 2 : 0); + return push_instr_uint(ctx, op, flags); + } + return push_instr(ctx, op) ? S_OK : E_OUTOFMEMORY; } @@ -1060,8 +1101,11 @@ static HRESULT compile_select_statement(compile_ctx_t *ctx, select_statement_t * unsigned end_label, case_cnt = 0, *case_labels = NULL, i; case_clausule_t *case_iter; expression_t *expr_iter; + BOOL test_lit; HRESULT hres; + test_lit = is_literal_expr(stat->expr); + hres = compile_expression(ctx, stat->expr); if(FAILED(hres)) return hres; @@ -1096,11 +1140,14 @@ static HRESULT compile_select_statement(compile_ctx_t *ctx, select_statement_t * break; for(expr_iter = case_iter->expr; expr_iter; expr_iter = expr_iter->next) { + unsigned flags = (test_lit ? 1 : 0) + | (is_literal_expr(expr_iter) ? 2 : 0); + hres = compile_expression(ctx, expr_iter); if(FAILED(hres)) break; - hres = push_instr_addr(ctx, OP_case, case_labels[i]); + hres = push_instr_addr_uint(ctx, OP_case, case_labels[i], flags); if(FAILED(hres)) break; diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 58afe4c6b41..65ef76f6e92 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -2110,16 +2110,26 @@ static HRESULT interp_imp(exec_ctx_t *ctx) static inline BOOL is_numeric_vt(VARTYPE vt) { return vt == VT_I2 || vt == VT_I4 || vt == VT_R4 || vt == VT_R8 - || vt == VT_CY || vt == VT_DATE || vt == VT_UI1; + || vt == VT_CY || vt == VT_DATE || vt == VT_UI1 || vt == VT_DECIMAL + || vt == VT_I1 || vt == VT_I8 || vt == VT_UI2 || vt == VT_UI4 + || vt == VT_UI8 || vt == VT_INT || vt == VT_UINT; } -static HRESULT var_cmp(exec_ctx_t *ctx, VARIANT *l, VARIANT *r) +/* l_lit / r_lit are set by the compiler: each side is true iff the source + * expression at the comparison site is a bare numeric literal. Windows VBScript + * dispatches BSTR-vs-numeric on this distinction (literal coerces, non-literal + * string-compares). */ +static HRESULT var_cmp(exec_ctx_t *ctx, VARIANT *l, VARIANT *r, BOOL l_lit, BOOL r_lit) { + VARTYPE lvt = V_VT(l) & VT_TYPEMASK; + VARTYPE rvt = V_VT(r) & VT_TYPEMASK; + TRACE("%s %s\n", debugstr_variant(l), debugstr_variant(r)); - /* VarCmp would use string comparison; VBScript converts the string to a number. */ - if((V_VT(l) == VT_BSTR && is_numeric_vt(V_VT(r))) || - (V_VT(r) == VT_BSTR && is_numeric_vt(V_VT(l)))) { + /* BSTR vs numeric LITERAL: coerce BSTR to a number, parse failure raises + * type-mismatch (error 13). */ + if((lvt == VT_BSTR && is_numeric_vt(rvt) && r_lit) || + (rvt == VT_BSTR && is_numeric_vt(lvt) && l_lit)) { double dl, dr; HRESULT hres; @@ -2136,10 +2146,38 @@ static HRESULT var_cmp(exec_ctx_t *ctx, VARIANT *l, VARIANT *r) return VARCMP_EQ; } + /* BSTR vs numeric (non-literal) or VT_BOOL: coerce the numeric/bool side + * to its CStr form and string-compare. No error on unparseable BSTR; + * relational uses binary lex order. VarBstrFromBool yields "-1"/"0" + * rather than VBScript's "True"/"False", so bool strings are hardcoded. */ + if((lvt == VT_BSTR && (is_numeric_vt(rvt) || rvt == VT_BOOL)) || + (rvt == VT_BSTR && (is_numeric_vt(lvt) || lvt == VT_BOOL))) { + VARIANT *num = lvt == VT_BSTR ? r : l; + VARIANT *str = lvt == VT_BSTR ? l : r; + VARIANT num_str; + HRESULT hres; + + VariantInit(&num_str); + if((V_VT(num) & VT_TYPEMASK) == VT_BOOL) { + V_VT(&num_str) = VT_BSTR; + V_BSTR(&num_str) = SysAllocString(V_BOOL(num) ? L"True" : L"False"); + if(!V_BSTR(&num_str)) + return E_OUTOFMEMORY; + }else { + hres = VariantChangeType(&num_str, num, 0, VT_BSTR); + if(FAILED(hres)) + return hres; + } + hres = lvt == VT_BSTR ? VarCmp(str, &num_str, 0, 0) + : VarCmp(&num_str, str, 0, 0); + VariantClear(&num_str); + return hres; + } + return VarCmp(l, r, ctx->script->lcid, 0); } -static HRESULT cmp_oper(exec_ctx_t *ctx) +static HRESULT cmp_oper(exec_ctx_t *ctx, BOOL l_lit, BOOL r_lit) { variant_val_t l, r; HRESULT hres; @@ -2150,7 +2188,7 @@ static HRESULT cmp_oper(exec_ctx_t *ctx) hres = stack_pop_val(ctx, &l); if(SUCCEEDED(hres)) { - hres = var_cmp(ctx, l.v, r.v); + hres = var_cmp(ctx, l.v, r.v, l_lit, r_lit); release_val(&l); } @@ -2160,12 +2198,13 @@ static HRESULT cmp_oper(exec_ctx_t *ctx) static HRESULT interp_equal(exec_ctx_t *ctx) { + const unsigned flags = ctx->instr->arg1.uint; VARIANT v; HRESULT hres; TRACE("\n"); - hres = cmp_oper(ctx); + hres = cmp_oper(ctx, flags & 1, flags & 2); if(FAILED(hres)) return hres; if(hres == VARCMP_NULL) @@ -2178,12 +2217,13 @@ static HRESULT interp_equal(exec_ctx_t *ctx) static HRESULT interp_nequal(exec_ctx_t *ctx) { + const unsigned flags = ctx->instr->arg1.uint; VARIANT v; HRESULT hres; TRACE("\n"); - hres = cmp_oper(ctx); + hres = cmp_oper(ctx, flags & 1, flags & 2); if(FAILED(hres)) return hres; if(hres == VARCMP_NULL) @@ -2196,12 +2236,13 @@ static HRESULT interp_nequal(exec_ctx_t *ctx) static HRESULT interp_gt(exec_ctx_t *ctx) { + const unsigned flags = ctx->instr->arg1.uint; VARIANT v; HRESULT hres; TRACE("\n"); - hres = cmp_oper(ctx); + hres = cmp_oper(ctx, flags & 1, flags & 2); if(FAILED(hres)) return hres; if(hres == VARCMP_NULL) @@ -2214,12 +2255,13 @@ static HRESULT interp_gt(exec_ctx_t *ctx) static HRESULT interp_gteq(exec_ctx_t *ctx) { + const unsigned flags = ctx->instr->arg1.uint; VARIANT v; HRESULT hres; TRACE("\n"); - hres = cmp_oper(ctx); + hres = cmp_oper(ctx, flags & 1, flags & 2); if(FAILED(hres)) return hres; if(hres == VARCMP_NULL) @@ -2232,12 +2274,13 @@ static HRESULT interp_gteq(exec_ctx_t *ctx) static HRESULT interp_lt(exec_ctx_t *ctx) { + const unsigned flags = ctx->instr->arg1.uint; VARIANT v; HRESULT hres; TRACE("\n"); - hres = cmp_oper(ctx); + hres = cmp_oper(ctx, flags & 1, flags & 2); if(FAILED(hres)) return hres; if(hres == VARCMP_NULL) @@ -2250,12 +2293,13 @@ static HRESULT interp_lt(exec_ctx_t *ctx) static HRESULT interp_lteq(exec_ctx_t *ctx) { + const unsigned flags = ctx->instr->arg1.uint; VARIANT v; HRESULT hres; TRACE("\n"); - hres = cmp_oper(ctx); + hres = cmp_oper(ctx, flags & 1, flags & 2); if(FAILED(hres)) return hres; if(hres == VARCMP_NULL) @@ -2269,6 +2313,7 @@ static HRESULT interp_lteq(exec_ctx_t *ctx) static HRESULT interp_case(exec_ctx_t *ctx) { const unsigned arg = ctx->instr->arg1.uint; + const unsigned flags = ctx->instr->arg2.uint; variant_val_t v; HRESULT hres; @@ -2278,7 +2323,7 @@ static HRESULT interp_case(exec_ctx_t *ctx) if(FAILED(hres)) return hres; - hres = var_cmp(ctx, stack_top(ctx, 0), v.v); + hres = var_cmp(ctx, stack_top(ctx, 0), v.v, flags & 1, flags & 2); release_val(&v); if(FAILED(hres)) { if(hres == DISP_E_TYPEMISMATCH) { diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 0e5462348b7..5fea53eb017 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -143,10 +143,32 @@ Call ok("05" = 5, """05"" = 5 should be true") Call ok(" 5" = 5, """ 5"" = 5 should be true") Call ok("5 " = 5, """5 "" = 5 should be true") Call ok("5e0" = 5, """5e0"" = 5 should be true") -' String vs Boolean uses string comparison, not numeric conversion +' BSTR vs Boolean: string-compare against CStr(bool) ("True"/"False"), +' case-sensitive, no whitespace trimming, no numeric coercion, no type-mismatch. +Call ok("True" = True, """True"" = True should be true") +Call ok("False" = False, """False"" = False should be true") +Call ok(not ("True" = False), """True"" = False should be false") +Call ok(not ("False" = True), """False"" = True should be false") +Call ok(not ("true" = True), """true"" = True should be false (case-sensitive)") +Call ok(not ("TRUE" = True), """TRUE"" = True should be false (case-sensitive)") +Call ok(not ("True " = True), """True "" = True should be false (no trim)") +Call ok(not (" True" = True), """ True"" = True should be false (no trim)") Call ok(not ("1" = True), """1"" = True should be false") Call ok(not ("-1" = True), """-1"" = True should be false") Call ok(not ("0" = False), """0"" = False should be false") +Call ok(not ("-1" = False), """-1"" = False should be false") +Call ok(not ("True" <> True), """True"" <> True should be false") +Call ok("False" <> True, """False"" <> True should be true") +Call ok(not ("abc" = True), """abc"" = True should be false (no error)") +Call ok(not ("" = True), """"" = True should be false (no error)") +Call ok(not ("" = False), """"" = False should be false (no error)") +Call ok(True = "True", "True = ""True"" should be true") +Call ok(False = "False", "False = ""False"" should be true") +' Relational: lexicographic string comparison after coercing bool to BSTR +Call ok("True" > False, """True"" > False should be true (lex)") +Call ok(not ("True" < False), """True"" < False should be false (lex)") +Call ok(not ("False" > True), """False"" > True should be false (lex)") +Call ok("abc" > True, """abc"" > True should be true (lex)") ' Non-numeric BSTR compared to number raises type mismatch (= / <> / relational) on error resume next err.clear @@ -200,94 +222,86 @@ Call ok("&H1F" = 31, """&H1F"" = 31 should be true") ' VT_UI1/VT_CY vs BSTR diverge from VT_I2: string-compare against CStr(numeric). ' Non-numeric BSTR returns False with NO error (VT_I2 raises 13 for the same). -on error resume next -err.clear -x = ("abc" = CByte(5)) -saved_err = err.number -err.clear -Call todo_wine_ok(saved_err = 0, """abc"" = CByte(5) should not raise error (err=" & saved_err & ")") -x = ("abc" = CCur(5)) -saved_err = err.number -err.clear -Call todo_wine_ok(saved_err = 0, """abc"" = CCur(5) should not raise error (err=" & saved_err & ")") -x = ("" = CByte(0)) -saved_err = err.number -err.clear -Call todo_wine_ok(saved_err = 0, """"" = CByte(0) should not raise error (err=" & saved_err & ")") -x = ("" = CCur(0)) -saved_err = err.number -err.clear -Call todo_wine_ok(saved_err = 0, """"" = CCur(0) should not raise error (err=" & saved_err & ")") -on error goto 0 +Call ok(not ("abc" = CByte(5)), """abc"" = CByte(5) should be false (no error)") +Call ok(not ("abc" = CCur(5)), """abc"" = CCur(5) should be false (no error)") +Call ok(not ("" = CByte(0)), """"" = CByte(0) should be false (no error)") +Call ok(not ("" = CCur(0)), """"" = CCur(0) should be false (no error)") ' Relational confirms lex compare: 10 > 5 numerically would be true; lex "10" < "5". -Call todo_wine_ok(not ("10" > CByte(5)), """10"" > CByte(5) should be false (lex)") -Call todo_wine_ok(not ("5" < CCur(10)), """5"" < CCur(10) should be false (lex)") +Call ok(not ("10" > CByte(5)), """10"" > CByte(5) should be false (lex)") +Call ok(not ("5" < CCur(10)), """5"" < CCur(10) should be false (lex)") ' --- BSTR vs numeric LITERAL: BSTR coerces to a number, parse failure raises 13. --- Dim saved_err on error resume next err.clear x = ("abc" = 5.5) : saved_err = err.number : err.clear -Call ok(saved_err = 13, "literal R8: ""abc"" = 5.5 should error 13 (got " & saved_err & ")") +Call ok(saved_err = 13, "literal R8: ""abc"" = 5.5 should error 13 (got " & saved_err & "; needs literal tracking)") x = ("abc" = 1e2) : saved_err = err.number : err.clear -Call ok(saved_err = 13, "literal sci: ""abc"" = 1e2 should error 13 (got " & saved_err & ")") +Call ok(saved_err = 13, "literal sci: ""abc"" = 1e2 should error 13 (got " & saved_err & "; needs literal tracking)") x = ("abc" = &hff) : saved_err = err.number : err.clear Call ok(saved_err = 13, "literal hex: ""abc"" = &hff should error 13 (got " & saved_err & ")") x = ("abc" = 100000) : saved_err = err.number : err.clear Call ok(saved_err = 13, "literal I4: ""abc"" = 100000 should error 13 (got " & saved_err & ")") x = ("abc" = #1/15/2024#): saved_err = err.number : err.clear -Call ok(saved_err = 13, "literal date: ""abc"" = #1/15/2024# should error 13 (got " & saved_err & ")") +Call ok(saved_err = 13, "literal date: ""abc"" = #1/15/2024# should error 13 (got " & saved_err & "; needs literal tracking)") on error goto 0 -' --- Variable holding a numeric loses "literal" status: string compare, no error. --- +' --- Variable holding a numeric / arithmetic / unary / function return --- +' VBScript on Windows treats these as non-literal: BSTR vs numeric uses +' string-compare, non-numeric BSTR returns False with no error. Wine doesn't +' track literal-ness, so VT_I2/I4 values still go through the numeric path +' and raise error 13, so these stay todo_wine until the literal-tracking work +' lands. We wrap each block in "on error resume next" so the script doesn't +' abort on the unwanted error. Dim n5 : n5 = 5 Dim n10 : n10 = 10 on error resume next err.clear x = ("abc" = n5) : saved_err = err.number : err.clear -on error goto 0 -Call todo_wine_ok(saved_err = 0, "var: ""abc"" = (n=5) should not raise (got " & saved_err & ")") -Call todo_wine_ok(not ("abc" = n5), "var: ""abc"" = (n=5) should be false") -Call todo_wine_ok(not ("010" = n10), "var: ""010"" = (n=10) should be false (string)") - -' --- Arithmetic / unary produce a fresh non-literal value. --- -on error resume next +Call ok(saved_err = 0, "var: ""abc"" = (n=5) should not raise (got " & saved_err & ")") +err.clear +x = ("abc" = n5) : Call ok(err.number = 0 and not x, "var: ""abc"" = (n=5) should be false") +err.clear +x = ("010" = n10) : Call ok(err.number = 0 and not x, "var: ""010"" = (n=10) should be false (string)") err.clear x = ("abc" = (5+0)) : saved_err = err.number : err.clear -on error goto 0 -Call todo_wine_ok(saved_err = 0, "arith: ""abc"" = (5+0) should not raise (got " & saved_err & ")") -Call todo_wine_ok(not ("010" = (5+5)), "arith: ""010"" = (5+5) should be false") -Call todo_wine_ok(not ("010" = (10*1)), "arith: ""010"" = (10*1) should be false") -on error resume next +Call ok(saved_err = 0, "arith: ""abc"" = (5+0) should not raise (got " & saved_err & ")") +err.clear +x = ("010" = (5+5)) : Call ok(err.number = 0 and not x, "arith: ""010"" = (5+5) should be false") +err.clear +x = ("010" = (10*1)) : Call ok(err.number = 0 and not x, "arith: ""010"" = (10*1) should be false") err.clear x = ("abc" = -5) : saved_err = err.number : err.clear +Call ok(saved_err = 0, "neg: ""abc"" = -5 should not raise (got " & saved_err & ")") on error goto 0 -Call todo_wine_ok(saved_err = 0, "neg: ""abc"" = -5 should not raise (got " & saved_err & ")") ' --- C-coercion functions return non-literal values. --- -Call todo_wine_ok(not ("010" = CInt(10)), "CInt: ""010"" = CInt(10) should be false") -Call todo_wine_ok(not ("010" = CLng(10)), "CLng: ""010"" = CLng(10) should be false") -Call todo_wine_ok(not ("010" = CSng(10)), "CSng: ""010"" = CSng(10) should be false") -Call todo_wine_ok(not ("010" = CDbl(10)), "CDbl: ""010"" = CDbl(10) should be false") +' VT_I2/I4 from CInt/CLng still go through the numeric path on Wine (no literal +' tracking), so these remain todo_wine. +Call ok(not ("010" = CInt(10)), "CInt: ""010"" = CInt(10) should be false") +Call ok(not ("010" = CLng(10)), "CLng: ""010"" = CLng(10) should be false") +' VT_R4/VT_R8 from CSng/CDbl take the string-compare path now. +Call ok(not ("010" = CSng(10)), "CSng: ""010"" = CSng(10) should be false") +Call ok(not ("010" = CDbl(10)), "CDbl: ""010"" = CDbl(10) should be false") on error resume next err.clear x = ("abc" = CInt(5)) : saved_err = err.number : err.clear -Call todo_wine_ok(saved_err = 0, "CInt: ""abc"" = CInt(5) should not raise (got " & saved_err & ")") +Call ok(saved_err = 0, "CInt: ""abc"" = CInt(5) should not raise (got " & saved_err & ")") err.clear x = ("abc" = CLng(5)) : saved_err = err.number : err.clear -Call todo_wine_ok(saved_err = 0, "CLng: ""abc"" = CLng(5) should not raise (got " & saved_err & ")") +Call ok(saved_err = 0, "CLng: ""abc"" = CLng(5) should not raise (got " & saved_err & ")") err.clear x = ("abc" = CSng(5)) : saved_err = err.number : err.clear -Call todo_wine_ok(saved_err = 0, "CSng: ""abc"" = CSng(5) should not raise (got " & saved_err & ")") +Call ok(saved_err = 0, "CSng: ""abc"" = CSng(5) should not raise (got " & saved_err & ")") err.clear x = ("abc" = CDbl(5)) : saved_err = err.number : err.clear -Call todo_wine_ok(saved_err = 0, "CDbl: ""abc"" = CDbl(5) should not raise (got " & saved_err & ")") +Call ok(saved_err = 0, "CDbl: ""abc"" = CDbl(5) should not raise (got " & saved_err & ")") on error goto 0 ' VT_R4 / VT_R8 from CSng/CDbl: relational uses lex compare. -Call todo_wine_ok(not ("10" > CDbl(5)), """10"" > CDbl(5) should be false (lex)") -Call todo_wine_ok(not ("10" > CSng(5)), """10"" > CSng(5) should be false (lex)") -Call todo_wine_ok(not ("9" < CDbl(10)), """9"" < CDbl(10) should be false (lex)") +Call ok(not ("10" > CDbl(5)), """10"" > CDbl(5) should be false (lex)") +Call ok(not ("10" > CSng(5)), """10"" > CSng(5) should be false (lex)") +Call ok(not ("9" < CDbl(10)), """9"" < CDbl(10) should be false (lex)") ' --- VT_DATE from CDate is non-literal: string compare, no error. --- Dim cdt : cdt = CDate("2024-01-15") @@ -295,7 +309,7 @@ on error resume next err.clear x = ("abc" = cdt) : saved_err = err.number : err.clear on error goto 0 -Call todo_wine_ok(saved_err = 0, "CDate: ""abc"" = CDate(...) should not raise (got " & saved_err & ")") +Call ok(saved_err = 0, "CDate: ""abc"" = CDate(...) should not raise (got " & saved_err & ")") ' --- Function return / ByVal / ByRef strip "literal" status. --- Function GetFiveLit() @@ -305,7 +319,7 @@ on error resume next err.clear x = ("abc" = GetFiveLit()) : saved_err = err.number : err.clear on error goto 0 -Call todo_wine_ok(saved_err = 0, "fn return: ""abc"" = GetFiveLit() should not raise (got " & saved_err & ")") +Call ok(saved_err = 0, "fn return: ""abc"" = GetFiveLit() should not raise (got " & saved_err & ")") Sub TestByValStripsLit(ByVal v) Dim local_err @@ -313,7 +327,7 @@ Sub TestByValStripsLit(ByVal v) err.clear x = ("abc" = v) : local_err = err.number : err.clear on error goto 0 - Call todo_wine_ok(local_err = 0, "ByVal: ""abc"" = v should not raise (got " & local_err & ")") + Call ok(local_err = 0, "ByVal: ""abc"" = v should not raise (got " & local_err & ")") End Sub TestByValStripsLit 5 @@ -323,20 +337,23 @@ Sub TestByRefStripsLit(ByRef v) err.clear x = ("abc" = v) : local_err = err.number : err.clear on error goto 0 - Call todo_wine_ok(local_err = 0, "ByRef: ""abc"" = v should not raise (got " & local_err & ")") + Call ok(local_err = 0, "ByRef: ""abc"" = v should not raise (got " & local_err & ")") End Sub Dim litvar : litvar = 5 TestByRefStripsLit litvar -' --- Const inlines at compile-time in Wine, so the value is treated as a -' literal and raises error 13; on Windows Const acts like a variable. -' Tracked separately from the var_cmp fix; remains todo_wine for now. --- +' Const references compile to an EXPR_MEMBER node so the comparison is +' tagged non-literal even though the value is inlined; "abc" = FIVE goes +' through the BSTR-vs-numeric string-compare path and returns False with +' no error. Const FIVE_C = 5 on error resume next err.clear -x = ("abc" = FIVE_C) : saved_err = err.number : err.clear +x = ("abc" = FIVE_C) +saved_err = err.number +err.clear on error goto 0 -Call todo_wine_ok(saved_err = 0, "Const: ""abc"" = FIVE should not raise (got " & saved_err & "; needs compile-time fix)") +Call ok(saved_err = 0, "Const: ""abc"" = FIVE should not raise (got " & saved_err & ")") Call ok(getVT(false) = "VT_BOOL", "getVT(false) is not VT_BOOL") Call ok(getVT(true) = "VT_BOOL", "getVT(true) is not VT_BOOL") diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 6ff6e8ff8eb..8dc92c92ec0 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -254,7 +254,7 @@ typedef enum { X(assign_member, 1, ARG_BSTR, ARG_UINT) \ X(bool, 1, ARG_INT, 0) \ X(catch, 1, ARG_ADDR, ARG_UINT) \ - X(case, 0, ARG_ADDR, 0) \ + X(case, 0, ARG_ADDR, ARG_UINT) \ X(concat, 1, 0, 0) \ X(const, 1, ARG_BSTR, 0) \ X(date, 1, ARG_DATE, 0) \ @@ -264,14 +264,14 @@ typedef enum { X(double, 1, ARG_DOUBLE, 0) \ X(empty, 1, 0, 0) \ X(enumnext, 0, ARG_ADDR, ARG_BSTR) \ - X(equal, 1, 0, 0) \ + X(equal, 1, ARG_UINT, 0) \ X(hres, 1, ARG_UINT, 0) \ X(errmode, 1, ARG_INT, 0) \ X(eqv, 1, 0, 0) \ X(erase, 1, ARG_BSTR, 0) \ X(exp, 1, 0, 0) \ - X(gt, 1, 0, 0) \ - X(gteq, 1, 0, 0) \ + X(gt, 1, ARG_UINT, 0) \ + X(gteq, 1, ARG_UINT, 0) \ X(icall, 1, ARG_BSTR, ARG_UINT) \ X(icallv, 1, ARG_BSTR, ARG_UINT) \ X(ident, 1, ARG_BSTR, 0) \ @@ -283,15 +283,15 @@ typedef enum { X(jmp, 0, ARG_ADDR, 0) \ X(jmp_false, 0, ARG_ADDR, 0) \ X(jmp_true, 0, ARG_ADDR, 0) \ - X(lt, 1, 0, 0) \ - X(lteq, 1, 0, 0) \ + X(lt, 1, ARG_UINT, 0) \ + X(lteq, 1, ARG_UINT, 0) \ X(mcall, 1, ARG_BSTR, ARG_UINT) \ X(mcallv, 1, ARG_BSTR, ARG_UINT) \ X(me, 1, 0, 0) \ X(mod, 1, 0, 0) \ X(mul, 1, 0, 0) \ X(neg, 1, 0, 0) \ - X(nequal, 1, 0, 0) \ + X(nequal, 1, ARG_UINT, 0) \ X(new, 1, ARG_STR, 0) \ X(newenum, 1, 0, 0) \ X(not, 1, 0, 0) \ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10775