Skip to content

Parse-Error: new-line in string interpolation expressions#50799

Closed
bernd5 wants to merge 3 commits intodotnet:masterfrom
bernd5:master
Closed

Parse-Error: new-line in string interpolation expressions#50799
bernd5 wants to merge 3 commits intodotnet:masterfrom
bernd5:master

Conversation

@bernd5
Copy link
Copy Markdown
Contributor

@bernd5 bernd5 commented Jan 26, 2021

See: #50742

@bernd5 bernd5 requested a review from a team as a code owner January 26, 2021 20:24
@ghost ghost added the Area-Compilers label Jan 26, 2021
@333fred
Copy link
Copy Markdown
Member

333fred commented Jan 26, 2021

The C# specification does not allow this today. https://github.com/dotnet/csharplang/blob/master/spec/lexical-structure.md#interpolated-string-literals

The grammar explicitly forbids newlines in the regular_balanced_text section. In fact, allowing the example you pointed out here is a spec violation, as by the spec verbatim strings shouldn't be allowed inside interpolated strings. Breaking that is almost certainly a backcompat change we wouldn't take, but I don't believe we're interested in breaking the spec further. If you would like to see a language change to accommodate this use case, you'll need to open a proposal on dotnet/csharplang and get a member of the LDT to champion it.

@333fred 333fred closed this Jan 26, 2021
@bernd5
Copy link
Copy Markdown
Contributor Author

bernd5 commented Nov 13, 2021

Implemented via #56853

bernd5 added a commit to bernd5/roslyn that referenced this pull request Nov 13, 2021
333fred pushed a commit that referenced this pull request Dec 13, 2021
* Add test "TestInterpolatedStringWithNewLinesInExpression()" which was implemented as part of #50799 and later realized via #56853
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants