-
Notifications
You must be signed in to change notification settings - Fork 790
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
Fix parsing interpolated strings with unmatched braces #14182
Conversation
Looking at the failing tests, I am starting to have some doubts about this fix. There are tests with inputs like: let TripleInTripleInterpolated = $"""123{456}789{"""012"""}345"""
let TripleInSingleInterpolated = $"123{456}789{"""012"""}345"
let TripleInVerbatimInterpolated = $"123{456}789{"""012"""}345"
let TripleInterpolatedInTripleInterpolated = $"""123{456}789{$"""012"""}345"""
let TripleInterpolatedInSingleInterpolated = $"123{456}789{$"""012"""}345"
let TripleInterpolatedInVerbatimInterpolated = $"123{456}789{$"""012"""}345" ensuring there's an "Invalid interpolated string" error for each line. And with my change, we will only correctly report the error on the first line, so it seems like legitimate regression. However, I am not so sure if this was fully intentional to begin with. We happen to have nicer errors in this case, because the lexer is optimistic and continues to hope that the open On the other hand, right now input like this: let s = $"Unescaped curly brace or unclosed interpolation expr -> {"
let s2 = "Some legit string literal that did nothing wrong"
let s3 = "Another good citizen" will result in false positive errors for s2 and s3 string literals (because the lexer keeps thinking it is in the context of an open interpolation expression). And of course FSI is broken by input like that (see #14160). So there's definitely something to fix, but idk if it is ok to regress on cases like the first example (to be clear though, it would still be a compilation error). |
67ebe1f
to
e93cd97
Compare
Two tests for unmatched curly brace in interpolated string
This splits two unit tests that were testing multiple cases in one go into multiple unit tests - one per each case. Note, that original tests were expecting an accurate error for each of multiple lines of malformed string literals. They would no longer pass with changes introduced by previous commits in this PR.
e93cd97
to
107a2b0
Compare
This reverts commit 947f2bb.
dotnet#14182)" (dotnet#14759)" This reverts commit aa1d1ce.
dotnet#14182)" (dotnet#14759)" This reverts commit aa1d1ce.
…ched braces" (dotnet#14760) * Revert "Fix parsing interpolated strings with unmatched braces (dotnet#14182)" This reverts commit 947f2bb. * Bump FSBuildVersion --------- Co-authored-by: Adam Boniecki <20281641+abonie@users.noreply.github.com>
Should fix #14160