Repository navigation
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Support
(a, b) => a + bas 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 usingmare errors for now, pending closures (#530).