You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Parenthesised call/vararg should adjust to a single value (§3.4) #254
Per Lua 5.3 §3.4: "function calls and vararg expressions, when used inside parentheses, are adjusted to one result". We currently strip parens at parse time, so (f()) and f() are indistinguishable in the AST. constructs.lua is fully deferred on this.
Add %Lua.AST.Expr.Paren{inner, meta} to lib/lua/ast/expr.ex. Add it to the union type.
In lib/lua/parser.ex, parse_paren_expr/1 currently returns the inner expression directly. Wrap only when the inner is Call, MethodCall, or Vararg (the multi-value cases). Other parenthesised expressions can stay unwrapped — there is no semantic difference.
In lib/lua/compiler/scope.ex, add a passthrough resolve_expr(%Expr.Paren{inner: e}, state) that recurses.
In lib/lua/compiler/codegen.ex:
gen_expr(%Expr.Paren{inner: %Expr.Call{}}, ctx) and the MethodCall variant emit a single-result call (force result_count: 1).
gen_expr(%Expr.Paren{inner: %Expr.Vararg{}}, ctx) emits a get_vararg that materialises only the first value.
For other inners, just forward to gen_expr(inner, ctx).
New test file pinning the spec example plus parens in return, multi-assign, and table-constructor positions.
Acceptance
New regression test in test/lua/vm/ covering the four positions where multi-value expansion happens (last arg, last RHS, return, last field of {...}).
constructs.lua either passes or progresses to a different failure. Replace its :all with a narrower range if anything remains.
Risk
Compiler IR changes touch several files. Verify nothing in the existing test suite (esp. test/lua/compiler/) pins the old "parens are transparent" behaviour for calls.
Activity