Read an F# triple-quoted literal that carries no layout - #771
Merged
Conversation
TryScanMultiLine rejected any multi-line literal whose content did not strip back to the layout convention. For C# that is right: a raw string not in that shape does not compile, so the content is something this never wrote. F# is the other case. Its triple-quoted literal is plain verbatim text and the layout is only an agreement between the code that renders a snapshot and the code that reads one back, so a hand-written literal with its content starting on the opening line - the idiomatic shape - is perfectly valid and its value is simply what it says. Rejecting those made them impossible to patch, and did so in the worst way: the two halves of the agreement disagreed. TryParse returned "not a string literal" while StripLayout, which is what a test library runs the value through, returned the same text unchanged, so the OriginalValue an F# producer sends as its anchor (FS0202 - no CallerArgumentExpression) could never match what the parser read. The snapshot reported "The expected argument of the call near line N is not a string literal" and stayed that way for the life of the file. Give TryScanMultiLine a layoutRequired flag: C# passes true, F# false and falls back to the verbatim newline-normalised content, which is the answer StripLayout already gives for the same text. ParseRejectsMalformedIndent pinned the old behaviour and becomes ParseKeepsContentWithNoLayoutToStrip, which also asserts the two readers agree.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TryScanMultiLine rejected any multi-line literal whose content did not strip back to the layout convention. For C# that is right: a raw string not in that shape does not compile, so the content is something this never wrote.
F# is the other case. Its triple-quoted literal is plain verbatim text and the layout is only an agreement between the code that renders a snapshot and the code that reads one back, so a hand-written literal with its content starting on the opening line - the idiomatic shape - is perfectly valid and its value is simply what it says.
Rejecting those made them impossible to patch, and did so in the worst way: the two halves of the agreement disagreed. TryParse returned "not a string literal" while StripLayout, which is what a test library runs the value through, returned the same text unchanged, so the OriginalValue an F# producer sends as its anchor (FS0202 - no CallerArgumentExpression) could never match what the parser read. The snapshot reported "The expected argument of the call near line N is not a string literal" and stayed that way for the life of the file.
Give TryScanMultiLine a layoutRequired flag: C# passes true, F# false and falls back to the verbatim newline-normalised content, which is the answer StripLayout already gives for the same text. ParseRejectsMalformedIndent pinned the old behaviour and becomes ParseKeepsContentWithNoLayoutToStrip, which also asserts the two readers agree.