-
-
Notifications
You must be signed in to change notification settings - Fork 80
Support Strings inside string interpolations #658
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
Conversation
Yes, of course. Can you show a few error messages here? Or add some (snapshot) tests so we can discuss them in the review?
We could probably always fall back to a range that includes the "full" string, if it's hard to generate more precise spans? |
Gladly. I'll share some examples when next I’m able.
I feel like I’m close to getting more specific spans that would provide more helpful errors so I’m not quite ready to give up on it yet. But if I’m unable to get it to work, this would be a good solution I think. |
Here is a list of example errors. They are quite unrealistic but simple. Example of a single missing closing bracket: >>> "{ "{"Hi"" }"
error: while parsing
┌─ <input:11>:1:4
│
1 │ "{ "{"Hi"" }"
│ ^^^^^^ Unterminated string Example of a single missing closing bracket with multiple nested interpolations: >>> "{ "{"Hi"} {"there"" }"
error: while parsing
┌─ <input:16>:1:4
│
1 │ "{ "{"Hi"} {"there"" }"
│ ^^^^^^^^^^^^^^^^ Unterminated string
>>> "{ "{"Hi" {"there"}" }"
error: while parsing
┌─ <input:17>:1:11
│
1 │ "{ "{"Hi" {"there"}" }"
│ ^ Unexpected '{' inside string interpolation Example of unterminated string inside nested interpolation: >>> "{ "{"Hi}" }"
error: while parsing
┌─ <input:12>:1:1
│
1 │ "{ "{"Hi}" }"
│ ^^^^^^^^^^^^^ Unterminated string Example of unterminated string with multiple nested interpolations: >>> "{ "{"Hi"} {"there}" }"
error: while parsing
┌─ <input:19>:1:1
│
1 │ "{ "{"Hi"} {"there}" }"
│ ^^^^^^^^^^^^^^^^^^^^^^^ Unterminated string
>>> "{ "{"Hi} {"there"}" }"
error: while parsing
┌─ <input:20>:1:1
│
1 │ "{ "{"Hi} {"there"}" }"
│ ^^^^^^^^^^^^^^^^^^^^^^^ Unterminated string
>>> "{ "{"Hi"} {"there} }"
error: while parsing
┌─ <input:21>:1:4
│
1 │ "{ "{"Hi"} {"there} }"
│ ^^^^^^^^^^^^^^^^^^^ Unterminated string |
9156a36
to
69aef06
Compare
69aef06
to
248d0be
Compare
I remembered I had been working on this and gave it another stab. I'm not sure what I think about all the decisions I made, but everything seems to work and error messages are good in all the common and many uncommon cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
This PR aims at supporting arbitrary strings inside string interpolations.
Progress on this so far:
I'm not sure if the errors are too bad, but I would like a second set of eyes on it if anyone are up for it. I'm having a bit of difficulty figuring out how it all connects to produce the errors and associated spans I get on a given invalid string.