Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post-process STRINGPART #15519

Closed
wants to merge 2 commits into from
Closed

Conversation

som-snytt
Copy link
Contributor

When getting the next part of an interpolation,
consisting of the literal part followed by the interpolated
identifier or expression, defer fetching the identifier
to postProcessToken. This ensures that lookahead at an
interpolation looks ahead only one token.

Fixes #15514

When getting the next part of an interpolation,
consisting of the literal part followed by the interpolated
identifier or expression, defer fetching the identifier
to postProcessToken. This ensures that lookahead at an
interpolation looks ahead only one token.
If there is already a next token, don't overwrite it.

Give a pass to lookahead scanner as a hedge, assuming
lookahead results are merely a probe and are discarded,
and may be looking at erroneous input.
@som-snytt
Copy link
Contributor Author

Added the assert on reset from the sibling PR.

@som-snytt som-snytt requested a review from odersky June 24, 2022 13:35
@som-snytt som-snytt marked this pull request as ready for review June 24, 2022 13:38
@@ -751,6 +751,8 @@ object Scanners {
closeIndented()
case EOF =>
if !source.maybeIncomplete then closeIndented()
case STRINGPART =>
finishStringPart()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A Finnish string part would be the violins in Sibelius's Finlandia.

Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

I must admit I found this hard to follow, and a bit unsystematic, since postProcess usually does not fiddle with token details like that.

I believe it's best to simply forbid looking ahead beyond an INTERPOLATIONID. It turned out forbidding this revealed a bug in Parser where the real problem lied.

@odersky odersky mentioned this pull request Jun 25, 2022
@som-snytt som-snytt closed this Jun 27, 2022
@som-snytt som-snytt deleted the issue/15514-postprocess branch February 6, 2023 07:28
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.

String interpolation followed by a dot is missing string literals
2 participants