Skip to content

Commit e2f4bfe

Browse files
committed
Add tests for unmatched curly brace
Two tests for unmatched curly brace in interpolated string
1 parent 6468fe5 commit e2f4bfe

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

tests/fsharp/Compiler/Language/StringInterpolation.fs

+32-3
Original file line numberDiff line numberDiff line change
@@ -803,17 +803,46 @@ let TripleInterpolatedInVerbatimInterpolated = $\"123{456}789{$\"\"\"012\"\"\"}3
803803
"Incomplete structured construct at or before this point in binding. Expected interpolated string (final part), interpolated string (part) or other token.");
804804
(FSharpDiagnosticSeverity.Error, 3379, (1, 38, 1, 39),
805805
"Incomplete interpolated string begun at or before here")|]
806-
806+
807807
[<Test>]
808-
let ``String interpolation negative incomplete string fill`` () =
808+
let ``String interpolation negative incomplete string with incomplete fill`` () =
809809
let code = """let x1 = $"one %d{System.String.Empty"""
810810
CompilerAssert.TypeCheckWithErrorsAndOptions [| "--langversion:5.0" |]
811811
code
812812
[|(FSharpDiagnosticSeverity.Error, 10, (1, 1, 1, 38),
813813
"Incomplete structured construct at or before this point in binding. Expected interpolated string (final part), interpolated string (part) or other token.");
814814
(FSharpDiagnosticSeverity.Error, 3378, (1, 18, 1, 19),
815815
"Incomplete interpolated string expression fill begun at or before here")|]
816-
816+
817+
[<Test>]
818+
let ``String interpolation negative incomplete fill`` () =
819+
let code = "let x1 = $\"one %d{System.String.Empty\""
820+
CompilerAssert.TypeCheckWithErrorsAndOptions [| "--langversion:5.0" |]
821+
code
822+
[|(FSharpDiagnosticSeverity.Error, 3373, (1, 38, 1, 39),
823+
"Invalid interpolated string. Single quote or verbatim string literals may not be used in interpolated expressions in single quote or verbatim strings. \
824+
Consider using an explicit 'let' binding for the interpolation expression or use a triple quote string as the outer string literal.");
825+
(FSharpDiagnosticSeverity.Error, 10, (1, 1, 1, 39),
826+
"Incomplete structured construct at or before this point in binding. Expected interpolated string (final part), interpolated string (part) or other token.");
827+
(FSharpDiagnosticSeverity.Error, 514, (1, 38, 1, 39),
828+
"End of file in string begun at or before here")|]
829+
830+
[<Test>]
831+
let ``String interpolation negative incomplete fill with another valid string`` () =
832+
let code = """
833+
let x1 = $"one %d{System.String.Empty"
834+
let x2 = "any old string"
835+
"""
836+
CompilerAssert.TypeCheckWithErrorsAndOptions [| "--langversion:5.0" |]
837+
code
838+
[|(FSharpDiagnosticSeverity.Error, 3373, (2, 38, 2, 39),
839+
"Invalid interpolated string. Single quote or verbatim string literals may not be used in interpolated expressions in single quote or verbatim strings. \
840+
Consider using an explicit 'let' binding for the interpolation expression or use a triple quote string as the outer string literal.");
841+
(FSharpDiagnosticSeverity.Error, 10, (4, 1, 4, 1),
842+
"Incomplete structured construct at or before this point in binding. Expected interpolated string (final part), interpolated string (part) or other token.");
843+
(FSharpDiagnosticSeverity.Error, 514, (3, 25, 3, 26),
844+
"End of file in string begun at or before here")|]
845+
817846
[<Test>]
818847
let ``String interpolation negative incomplete verbatim string`` () =
819848
let code = """let x1 = @$"one %d{System.String.Empty} """

0 commit comments

Comments
 (0)