Sitelet https://github.com/starkware-libs/cairo/pull/10020
Skip to content

fix(syntax): include TokenMissing in generated is_missing() generate_kinds_code built the missing-kinds set only from enum missing_variant nodes, so SyntaxKind::TokenMissing was excluded and is_missing() returned false for it. The inline-macro expan - #10020

Merged
orizi merged 1 commit into
mainfrom
orizi/fix-syntax-token-missing-is-missing
Jun 1, 2026

Conversation

@orizi

@orizi orizi commented Jun 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

TokenMissing is now included in the is_missing classification for SyntaxKind, and macro calls that contain a missing token (i.e., a parse error) are no longer expanded — the parse error diagnostic is considered sufficient. A test case is added to confirm that an incomplete macro invocation like array![1, 2 produces only the missing token parse error and is left unexpanded.


Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

Why is this change needed?

When a macro call contained a missing token due to a parse error, the macro expander would still attempt to expand it, potentially producing confusing or redundant diagnostics. The root cause was that TokenMissing was not recognized as a "missing" kind in SyntaxKind::is_missing, so the expander had no way to detect this condition and bail out early.


What was the behavior or documentation before?

TokenMissing was not included in SyntaxKind::is_missing, so macro calls with missing tokens (e.g., an unclosed bracket) could still be passed to the macro expander, leading to expansion attempts on malformed syntax.


What is the behavior or documentation after?

TokenMissing is now recognized by SyntaxKind::is_missing. Macro calls that contain a missing token are skipped during expansion, and only the original parse error diagnostic (e.g., Missing token ']') is reported.


Related issue or discussion (if any)

N/A


Additional context

The code generation for missing_kinds in generator.rs was also updated to include TokenMissing alongside enum missing variants, ensuring the generated kind classification stays consistent with the new behavior.

generate_kinds_code built the missing-kinds set only from enum
  `missing_variant` nodes, so SyntaxKind::TokenMissing was excluded and
  is_missing() returned false for it. The inline-macro expansion guards that
  skip expansion when the call has a parse error (via is_missing()) therefore
  missed errors manifesting solely as a missing token, and tried to expand
  broken input. Emit the Token "Missing" node alongside the enum *Missing
  variants and regenerate kind.rs.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

@orizi
orizi marked this pull request as ready for review June 1, 2026 07:45
@cursor

cursor Bot commented Jun 1, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Small syntax-classification and diagnostic-behavior fix in the compiler frontend; no auth, runtime, or data-path changes.

Overview
SyntaxKind::is_missing() now treats TokenMissing as a missing kind. Syntax codegen’s missing_kinds set was extended beyond enum missing_variant entries so TokenMissing is generated into is_missing() (and kind.rs is updated accordingly).

With that fix, inline macro expansion can detect parse-recovery placeholders in the macro call’s syntax tree and bail out instead of expanding on broken input—so callers only see the original parse diagnostic (e.g. missing ]).

An expansion test asserts that array![1, 2 stays unexpanded and reports Missing token ']' only.

Reviewed by Cursor Bugbot for commit fe2a1ff. Bugbot is set up for automated code reviews on this repo. Configure here.

@TomerStarkware TomerStarkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

:lgtm:

@TomerStarkware reviewed 3 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).

@orizi
orizi added this pull request to the merge queue Jun 1, 2026
Merged via the queue into main with commit b61822d Jun 1, 2026
54 checks passed
@orizi
orizi deleted the orizi/fix-syntax-token-missing-is-missing branch June 1, 2026 09:34
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.

3 participants