Skip to content

a comment behind the arrow of a lambda ends the statement - #154

Merged
Galvarcus merged 1 commit into
Developmentfrom
151-comment-after-arrow
Nov 15, 2026
Merged

Galvarcus merged 1 commit into
Developmentfrom
151-comment-after-arrow

Conversation

@Galvarcus

Copy link
Copy Markdown
Owner

Vim9 carries a line that ends with => on to the body of the lambda on the next line (#94). The lexer read that end from the raw text, so a comment behind the arrow hid it. The statement then ended at the arrow, and the body became a statement of its own, where the parameters of the lambda were names.

code_ends now reads the last tokens of a line other than a comment, for the arrow alone and for the arrow and the brace that open a block lambda (#147), which it replaces.

fixes: #151

AI assistance

  • AI involvement is disclosed in the commit message

Checklist

  • The commit message follows the Problem and Solution form above
  • tools/check prints every check passed
  • The Signed-off-by: trailer is present, which the
    prepare-commit-msg hook adds. A fresh checkout has no hooks,
    so install them again before the first commit

Tests

  • Tests were added, and each was watched failing first

a_lambda_parameter_read_after_a_comment_behind_the_arrow_is_no_reference in tests/vim9_syntax.rs fails on lnum without the change.

What the analyzer reports

  • No finding moves, and every parity fixture matches

The four corpora and the survey report the same as before.

Documentation

  • No documentation update is needed

Anything reviewers should know

The cloud review of Development against main found this fault. A dot that ends a line of a lambda block still reaches into the next line, which this change does not touch; it is #153.

Problem:  A comment behind the arrow of a lambda ends the statement.
Solution: Read whether a line ends with the arrow from its tokens, past
          a comment (Galvarcus).

Vim9 carries a line that ends with `=>` on to the body of the lambda on
the next line (#94). The lexer read that end from the raw text, so a
comment behind the arrow hid it. The statement then ended at the arrow,
and the body became a statement of its own, where the parameters of the
lambda were names.

code_ends now reads the last tokens of a line other than a comment, for
the arrow alone and for the arrow and the brace that open a block lambda
(#147), which it replaces.

The four corpora and the survey report the same as before.

fixes:   #151
related: #94
related: #147
related: #140

Assisted-by: Claude Opus 5
Signed-off-by: Galvarcus <117151435+Galvarcus@users.noreply.github.com>
@Galvarcus Galvarcus self-assigned this Nov 15, 2026
@github-actions github-actions Bot added the analyzer Changes the Rust analyzer, the fixtures, or the tools that build them label Nov 15, 2026
@Galvarcus
Galvarcus merged commit 4074636 into Development Nov 15, 2026
9 checks passed
@Galvarcus
Galvarcus deleted the 151-comment-after-arrow branch November 15, 2026 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

analyzer Changes the Rust analyzer, the fixtures, or the tools that build them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant