Skip to content

✨ feat(lang): add -> (Arrow) syntax as shorthand for fn#1664

Merged
harehare merged 2 commits into
mainfrom
feat/arrow-syntax
Apr 29, 2026
Merged

✨ feat(lang): add -> (Arrow) syntax as shorthand for fn#1664
harehare merged 2 commits into
mainfrom
feat/arrow-syntax

Conversation

@harehare

Copy link
Copy Markdown
Owner

Add Arrow (->) as an alternative syntax for anonymous functions, equivalent to fn. Includes lexer token, CST/AST parser support, formatter support, and tests for all layers.

Also fix CST parse_arg() to accept Arrow tokens so -> can be used as a function call argument (e.g. map(->(): ...)).

Add Arrow (->) as an alternative syntax for anonymous functions,
equivalent to fn. Includes lexer token, CST/AST parser support,
formatter support, and tests for all layers.

Also fix CST parse_arg() to accept Arrow tokens so -> can be
used as a function call argument (e.g. map(->(): ...)).
@harehare harehare marked this pull request as ready for review April 29, 2026 02:09
@codspeed-hq

codspeed-hq Bot commented Apr 29, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 29 untouched benchmarks


Comparing feat/arrow-syntax (1649d5f) with main (f531b14)

Open in CodSpeed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds -> (Arrow) as an alternative surface syntax for anonymous functions in mq-lang, integrating it through lexing, CST/AST parsing, and formatting, with accompanying tests to ensure consistent behavior across layers.

Changes:

  • Introduce TokenKind::Arrow and lex -> as its own token.
  • Extend CST and AST parsers to treat Arrow equivalently to fn, including allowing it as a call argument.
  • Add formatter test coverage for arrow-function formatting scenarios.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/mq-lang/src/lexer/token.rs Adds TokenKind::Arrow and display formatting/tests for ->.
crates/mq-lang/src/lexer.rs Adds lexer support and tokenization tests for the -> token.
crates/mq-lang/src/cst/parser.rs Allows -> wherever fn is accepted (including call args) and adds CST tests.
crates/mq-lang/src/ast/parser.rs Accepts -> as a fn equivalent in the AST parser and adds AST tests.
crates/mq-formatter/src/formatter.rs Adds formatter tests validating arrow-function output and spacing/newline behavior.

Comment thread crates/mq-lang/src/lexer/token.rs
Comment thread crates/mq-lang/src/lexer.rs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread crates/mq-lang/src/lexer/token.rs
@harehare harehare merged commit f8f1177 into main Apr 29, 2026
10 checks passed
@harehare harehare deleted the feat/arrow-syntax branch April 29, 2026 13:02
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.

2 participants