From: Francis De Brabandere <francisdb@gmail.com> Native cscript parses every 4-digit hex literal that fits 16 bits as Integer except &H8000: its value -32768 (INT16_MIN) has no positive Int16 representation, so native promotes it to Long. Wine returned Integer for that one case because interp_int narrows any value that fits VT_I2. Skip narrowing for INT16_MIN in interp_int. The only OP_int call site that emits this value is the hex/oct lexer; unary `-32768` is two ops (push 32768, then neg) so it isn't affected. --- dlls/vbscript/interp.c | 6 +++++- dlls/vbscript/tests/lang.vbs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 219b4fdefda..e8712b343ea 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -1993,7 +1993,11 @@ static HRESULT interp_int(exec_ctx_t *ctx) TRACE("%ld\n", arg); - if(arg == (INT16)arg) { + /* INT16_MIN is the one I2-fitting value native always parses as Long: it + * has no positive Int16 representation, so &H8000 / decimal 32768 etc. + * produce a Long literal. The only OP_int call site that emits this value + * is the hex/oct lexer; unary `-32768` is two ops (push 32768, then neg). */ + if(arg == (INT16)arg && arg != INT16_MIN) { V_VT(&v) = VT_I2; V_I2(&v) = arg; }else { diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 01f86406965..ef5b3445b39 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -76,7 +76,7 @@ Call ok(&h0 = 0, "&h0 <> 0") ' &H8000 (INT16_MIN bit pattern) is the one 16-bit value parsed as Long, not ' Integer: -32768 has no positive Int16 representation, so native promotes it. Call ok(&H8000 = -32768, "&H8000 <> -32768") -todo_wine_ok getVT(&H8000) = "VT_I4", "getVT(&H8000) is not VT_I4" +Call ok(getVT(&H8000) = "VT_I4", "getVT(&H8000) is not VT_I4") Call ok(&H8001 = -32767, "&H8001 <> -32767") Call ok(getVT(&H8001) = "VT_I2", "getVT(&H8001) is not VT_I2") Call ok(&H7FFF = 32767, "&H7FFF <> 32767") -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10907