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

Remove buggy fromString insertion with string interpolation #1755

Closed
andrevidela opened this issue Jul 18, 2021 · 1 comment · Fixed by #1769
Closed

Remove buggy fromString insertion with string interpolation #1755

andrevidela opened this issue Jul 18, 2021 · 1 comment · Fixed by #1769

Comments

@andrevidela
Copy link
Collaborator

When using string interpolation the compiler inserts fromString calls at the wrong places. The details in #555 indicate that attempting to support fromString in interpolated string leads to inconsistent and unpredictable behaviour. A more moral argument is that interpolated strings are meant to concatenate strings specifically.

Steps to Reproduce

Use

"hello \{"world"} !"

Expected Behavior

The tree should return

"hello " ++ "world" ++ " !"

for the reason highlighted in #555

Observed Behavior

The tree is instead

fromString "hello" ++ fromString "world" ++ " !"
@andrevidela
Copy link
Collaborator Author

It turns out we cannot remove the fromString from the "world" call because we cannot guess what the type of its expression should be. In the example I assumed it was possible to assume each string literal in an interpolated slice evaluates to a string but that is not the case:

"Take this path: \{ show ("path" / "to" / "file") } for example"

Here the quotes within an interpolated slice must have the fromString call otherwise this expression wouldn't typecheck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant