Skip to content

Fix unsubstituted '%s' in error message for 'for' loop missing 'in' - #46

Merged
Tobias-Kohn merged 1 commit into
Tobias-Kohn:masterfrom
neilccbrown:fix-for-missing-in-message
Aug 3, 2026
Merged

Tobias-Kohn merged 1 commit into
Tobias-Kohn:masterfrom
neilccbrown:fix-for-missing-in-message

Conversation

@neilccbrown

Copy link
Copy Markdown
Contributor

I noticed in Strype if you just type "for" on a line, you see this literal message: "'%s' required but '%s' found.". This tiny PR fixes that.

More detail: When a for-statement's target is not followed by 'in' and there are no more tokens on the line (e.g. just 'for x' or just 'for'), ParserState.reportError's TokenBuffer overload reports TOKEN_REQUIRED with only one of its two required parameters, since the auto-padding logic in _reportError is bypassed once the token stream is exhausted. String.format then throws and the raw template ('%s' required but '%s' found.) is shown verbatim.

Report MISSING_TOKEN instead in that case, matching the same convention already used by TokenBuffer.requireType for an exhausted token stream.

When a for-statement's target is not followed by 'in' and there are no
more tokens on the line (e.g. just 'for x'), ParserState.reportError's
TokenBuffer overload reports TOKEN_REQUIRED with only one of its two
required parameters, since the auto-padding logic in _reportError is
bypassed once the token stream is exhausted. String.format then throws
and the raw template ('%s' required but '%s' found.) is shown verbatim.

Report MISSING_TOKEN instead in that case, matching the same convention
already used by TokenBuffer.requireType for an exhausted token stream.
@Tobias-Kohn
Tobias-Kohn merged commit 7dcb4ec into Tobias-Kohn:master Aug 3, 2026
1 check passed
@Tobias-Kohn

Copy link
Copy Markdown
Owner

Brilliant, thank you!

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