diff --git a/docs/release-notes/.FSharp.Compiler.Service/11.0.0.md b/docs/release-notes/.FSharp.Compiler.Service/11.0.0.md index c8bbf2156ce..5f2d1149fed 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/11.0.0.md +++ b/docs/release-notes/.FSharp.Compiler.Service/11.0.0.md @@ -21,6 +21,7 @@ * Type checker: recover on checking binding parameter constraints ([#19046](https://github.com/dotnet/fsharp/pull/19046)) * Debugger: provide breakpoint ranges for short lambdas ([#19067](https://github.com/dotnet/fsharp/pull/19067)) * FSharpDiagnostic: add default severity ([#19152](https://github.com/dotnet/fsharp/pull/19152)) +* Add support for triple quoted ASCII byte string ([#19182](https://github.com/dotnet/fsharp/pull/19182)) ### Changed diff --git a/src/Compiler/lex.fsl b/src/Compiler/lex.fsl index 1f905bc049a..7b8d8735fea 100644 --- a/src/Compiler/lex.fsl +++ b/src/Compiler/lex.fsl @@ -1502,6 +1502,12 @@ and tripleQuoteString (sargs: LexerStringArgs) (skip: bool) = parse let cont = LexCont.Token(args.ifdefStack, args.stringNest) fin.Finish buf kind LexerStringFinisherContext.TripleQuote cont } + | '"' '"' '"' 'B' + { let (buf, fin, _m, kind, args) = sargs + args.interpolationDelimiterLength <- 0 + let cont = LexCont.Token(args.ifdefStack, args.stringNest) + fin.Finish buf { kind with IsByteString = true } LexerStringFinisherContext.TripleQuote cont } + | newline { let (buf, _fin, m, kind, args) = sargs incrLine lexbuf diff --git a/tests/fsharp/Compiler/Conformance/BasicGrammarElements/BasicConstants.fs b/tests/fsharp/Compiler/Conformance/BasicGrammarElements/BasicConstants.fs index 5606ff7bc79..bc9bdc61dad 100644 --- a/tests/fsharp/Compiler/Conformance/BasicGrammarElements/BasicConstants.fs +++ b/tests/fsharp/Compiler/Conformance/BasicGrammarElements/BasicConstants.fs @@ -9,8 +9,10 @@ module ``Basic Grammar Element Constants`` = [] let ``Basic constants compile `` () = + let tripleQuotedByteString = " \"\"\" \" \"\"\"B " + CompilerAssert.Pass - """ + $""" let sbyteConst = 1y let int16Const = 1us let int32Const = 1ul @@ -42,6 +44,8 @@ let charConst = '1' let stringConst = "1" let bytestringConst = "1"B + +let byteTripleQuotedStringConst = {tripleQuotedByteString} let bytecharConst = '1'B