-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Interpolated string handler lowering isn't unescaping {{ and }} #54703
Comments
It is not the job of the C# compiler to do escaping here. This is the equivalent of |
I completely disagree. A key tenet of this feature is the compiler is already parsing the strings at compile-time and emitting the literals to be appended so no parsing is required at run-time. The C# compiler needs to do the escaping. |
I'll send an email to LDM to get approval for a spec change here and get a PR out to change this while we wait for approval. |
Fixes dotnet#54703. Spec change is at dotnet/csharplang#4910. Note that there is an interesting wrinkle here in that, for an interpolated string used as a string, the change in constant value makes the lowering mechanism an observable side effect. While doing this step during lowering instead of initial binding is technically feasible, it would be quite complex as there are several different ways an AppendLiteral call could get to lowering (dynamic, conversion to object, regular literal, passed by in, etc). For now, I'm opting for simple strategy of accepting this observable side-effect, and if we want to try and make that side effect invisble we can look at doing so at a later point.
* Unescape interpolated string literal components Fixes #54703. Spec change is at dotnet/csharplang#4910. Note that there is an interesting wrinkle here in that, for an interpolated string used as a string, the change in constant value makes the lowering mechanism an observable side effect. While doing this step during lowering instead of initial binding is technically feasible, it would be quite complex as there are several different ways an AppendLiteral call could get to lowering (dynamic, conversion to object, regular literal, passed by in, etc). For now, I'm opting for simple strategy of accepting this observable side-effect, and if we want to try and make that side effect invisble we can look at doing so at a later point. Co-authored-by: Jared Parsons <[email protected]>
Version Used:
1119ab9
Steps to Reproduce:
https://sharplab.io/#v2:EYLgZgpghgLgrgJwgZwLQEsB2MIIA4D2ANrBACarIwJYDmAPgMSZxEnBEQAEEmUHEALAAoAAIAmAIwjRAZi4SuAYREBvEV00L5oyQAYuAWQAUWGF3QBKLgF4AfFwAkAIlWquq9AF8uXr84BuES8RET4AWxQ8KABjbl0AOgAlOGx0SISlAnC8dE4EAGVcADd0OOQ1DS0AbUSAQRhqdGA4HABVZChaCAamlpxjesaafog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kXPrIYxsLww4krNzXLaJ/MSZtynYGpszdas/XncNxGvuLH2ebu9x1pMnKtod+WDeZo24/0BP1bU6StYD6SzVJidpY+sO2Ajx75Fi3AaHiicuDGAgG35NastTza8sjlu24bOoCSUThJk75Pu9Mzc+53LwgA==
Expected Behavior:
This should produce the equivalent of
"{ " + i + " }"
.Actual Behavior:
Instead it's producing the equivalent of
"{{ " + i + " }}"
.This is a behavioral regression.
cc: @333fred
The text was updated successfully, but these errors were encountered: