Skip to content

Conversation

tgodzik
Copy link
Collaborator

@tgodzik tgodzik commented Aug 27, 2024

Related to scalameta/metals#6699

It seems the code is perfectly reachable after all, so maybe it's better to default to invalid.

The other option I was thinking about (or an additional) is to finish interpolation splice right away with and End, but that might be too complex for a case that might not pop up that often.

@tgodzik tgodzik requested a review from kitbellew August 27, 2024 16:19
@tgodzik tgodzik force-pushed the broken-interpolator branch from 46c0038 to a941cbe Compare August 27, 2024 16:33

// the rest of tokens shouldn't be obtained via this method
case _ => unreachable(debug(curr))
case _ => getInvalid(curr, curr.strVal)
Copy link
Collaborator

Choose a reason for hiding this comment

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

so what type of token was attempted here? just want to be sure we're not masking a problem elsewhere.so what type of token was attempted here? just want to be sure we're not masking a problem elsewhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

STRINGPART since we have invalid token on single $ we then have a normal string contents

Copy link
Collaborator

Choose a reason for hiding this comment

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

keeping getInvalid is a good idea, just in case. do you think we should adjust getInvalid to include the LegacyToken that was parsed? for debugging purposes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I split the cases again and added a proper message which includes that info whenever unexpected token was found

|Interpolation.Start(''') [2..5)
|Interpolation.Part(|Available languages (default = ) [5..37)
|Interpolation.SpliceStart [37..38)
|Invalid(Not one of: `$'_, `$$', `$'ident, `$'this, `$'BlockExpr) [38..38)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed it a bit and I think it's currently the best option. Splice starts, but is broken, so we continue with normal string part and an invalid token.

@tgodzik tgodzik force-pushed the broken-interpolator branch from f75e64d to eae341d Compare August 27, 2024 16:54

// the rest of tokens shouldn't be obtained via this method
case _ => unreachable(debug(curr))
case _ => getInvalid(curr, curr.strVal)
Copy link
Collaborator

Choose a reason for hiding this comment

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

keeping getInvalid is a good idea, just in case. do you think we should adjust getInvalid to include the LegacyToken that was parsed? for debugging purposes?

@tgodzik tgodzik requested a review from kitbellew August 27, 2024 17:58
@kitbellew kitbellew merged commit 65bde5e into scalameta:main Aug 27, 2024
24 checks passed
@kitbellew
Copy link
Collaborator

@tgodzik i merged but perhaps you'd like to remove your branch if it's not automatically removed.

@tgodzik tgodzik deleted the broken-interpolator branch August 28, 2024 09:11
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