Repository navigation
Stim: accept blank and comment-only lines before a block's closing brace - #4348
Open
Mateus Anacleto (imateusdev) wants to merge 1 commit into
Open
Mateus Anacleto (imateusdev) wants to merge 1 commit into
Mateus Anacleto (imateusdev) wants to merge 1 commit into
Conversation
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
Mateus Anacleto (imateusdev)
requested review from
Bill Ticehurst (billti),
João Boechat (joao-boechat) and
orpuente-MS
as code owners
December 1, 2026 20:44
Author
|
@microsoft-github-policy-service agree |
This branch has not been deployed
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.
Fixes #4312.
parse_blockchecked forClose(Brace)before it skipped newlines. The lexer turns a comment-only line, or a blank line, into aNewlinetoken. When one comes right before}, the loop calledparse_item, which skipped the newline, found}and reportedexpected instruction_name, found close(brace), followed byUnexpectedEof. The block loop now skips newlines first and stops at}or at end of input. End of input still reaches theexpect_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_bracecomment_only_line_before_nested_closing_braces: comment-only lines before both an inner and an outer}.All three fail on
mainwith the error from the issue and pass with this change.cargo test -p stim_compiler --libpasses (861 tests), andcargo clippy -p stim_compiler --libandrustfmt --checkare clean on Windows 11 with Rust 1.97.