Skip to content

Add arrow function expressions (#1929) - #1931

Draft
iObject wants to merge 2 commits into
v1from
1929-arrow-function-support
Draft

iObject wants to merge 2 commits into
v1from
1929-arrow-function-support

Conversation

@iObject

@iObject iObject commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

Support (a, b) => a + b as sugar for an anonymous function that returns its expression. Arrows are FunctionExpressions with a synthesized return, so hover, validation and transpile work unchanged. Capturing enclosing locals and using m are errors for now, pending closures (#530).

Support `(a, b) => a + b` as sugar for an anonymous function that returns
its expression. Arrows are FunctionExpressions with a synthesized return,
so hover, validation and transpile work unchanged. Capturing enclosing
locals and using `m` are errors for now, pending closures (#530).
A local declared after an arrow function (`f = (x) => x + later` then
`later = 1`) was reported twice: CrossScopeValidator emitted
`cannot-find-name` while ScopeValidator emitted
`arrow-function-cannot-capture-variable`. Move the capture check into
`util.getArrowFunctionCaptureDiagnostic()` and use it from both
validators so they produce the same diagnostic and it collapses to one,
matching how plain anonymous functions already behave.

Grow the arrow function spec from 36 to 140 cases: all parameter and
body forms, every expression context, non-regression for groupings and
parenthesized typecasts, locations and AST links, parser diagnostics,
full transpile output for each lowering (including `sub` lowering for
sub/void/namespaced callees and the parenthesized-AA, template-string,
`??` and ternary bodies), return type inference, capture and `m`
validation across nesting, classes and loops, function-type
compatibility, and editor features (hover, completions, definition,
semantic tokens). Add lexer cases for `=>` without whitespace and its
token location.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant