Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Stim: accept blank and comment-only lines before a block's closing brace - #4348

Open
Mateus Anacleto (imateusdev) wants to merge 1 commit into
microsoft:mainfrom
imateusdev:stim-comment-before-closing-brace
Open

Mateus Anacleto (imateusdev) wants to merge 1 commit into
microsoft:mainfrom
imateusdev:stim-comment-before-closing-brace

Conversation

@imateusdev

Copy link
Copy Markdown

Fixes #4312.

parse_block checked for Close(Brace) before it skipped newlines. The lexer turns a comment-only line, or a blank line, into a Newline token. When one comes right before }, the loop called parse_item, which skipped the newline, found } and reported expected instruction_name, found close(brace), followed by UnexpectedEof. The block loop now skips newlines first and stops at } or at end of input. End of input still reaches the expect_token(Close(Brace)) that reports an unclosed block.

The issue reports the comment-only line. A blank line before } failed the same way, so it is covered too.

Tests

New parser tests in parser/tests/blocks.rs:

  • comment_only_line_before_closing_brace: the program from the issue.
  • blank_line_before_closing_brace
  • comment_only_line_before_nested_closing_braces: comment-only lines before both an inner and an outer }.

All three fail on main with the error from the issue and pass with this change. cargo test -p stim_compiler --lib passes (861 tests), and cargo clippy -p stim_compiler --lib and rustfmt --check are clean on Windows 11 with Rust 1.97.

parse_block checked for the closing brace before skipping newlines. The
lexer turns a comment-only or blank line into a newline token, so one
right before `}` reached parse_item, which skipped it, found the brace
and reported "expected instruction_name, found close(brace)". Skip
newlines first, then look for the brace.

Fixes microsoft#4312
@imateusdev

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

This branch has not been deployed

No deployments
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.

[Stim] Comment-only line before a REPEAT block's closing brace fails to parse

1 participant