From: Francis De Brabandere <francisdb@gmail.com> The lexer only treated '(' as call-argument parentheses after tIdentifier or ')'. After tME, it was emitted as tEXPRLBRACKET, causing Me(Idx) to fail with a syntax error. Add tME to the check so the parentheses are correctly recognized as call arguments. Also handle EXPR_ME in make_call_expression() so that Me(Idx) used as a statement (without 'Call') is wrapped as a call expression. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58248 --- dlls/vbscript/lex.c | 2 +- dlls/vbscript/parser.y | 2 +- dlls/vbscript/tests/lang.vbs | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c index 8c5c69ea429..75838ac586a 100644 --- a/dlls/vbscript/lex.c +++ b/dlls/vbscript/lex.c @@ -465,7 +465,7 @@ static int parse_next_token(void *lval, unsigned *loc, parser_ctx_t *ctx) * Parser can't predict if bracket is part of argument expression or an argument * in call expression. We predict it here instead. */ - if(ctx->last_token == tIdentifier || ctx->last_token == ')') + if(ctx->last_token == tIdentifier || ctx->last_token == ')' || ctx->last_token == tME) return '('; return tEXPRLBRACKET; case '"': diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index c5d2764562e..94a8896fe12 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -730,7 +730,7 @@ static call_expression_t *make_call_expression(parser_ctx_t *ctx, expression_t * { call_expression_t *call_expr; - if(callee_expr->type == EXPR_MEMBER) + if(callee_expr->type == EXPR_MEMBER || callee_expr->type == EXPR_ME) return new_call_expression(ctx, callee_expr, arguments); if(callee_expr->type != EXPR_CALL) { FIXME("Unhandled for expr type %u\n", callee_expr->type); diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 12d91a16548..26a0f8a833f 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -1382,6 +1382,25 @@ End Class Set obj = New TestMe Call obj.test(obj) +Class TestMeIndex + Private arr_(1) + Public Default Property Get Item(idx) + Item = arr_(idx) + End Property + Public Sub SetVal(idx, val) + arr_(idx) = val + End Sub + Public Sub TestAccess() + SetVal 0, "hello" + SetVal 1, "world" + Call ok(Me(0) = "hello", "Me(0) = " & Me(0)) + Call ok(Me(1) = "world", "Me(1) = " & Me(1)) + End Sub +End Class + +Set obj = New TestMeIndex +Call obj.TestAccess() + Call ok(getVT(test) = "VT_DISPATCH", "getVT(test) = " & getVT(test)) Call ok(Me is Test, "Me is not Test") -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10371