From 12df5a90efacd898f023718ed53d4df652773bd6 Mon Sep 17 00:00:00 2001 From: kerams Date: Mon, 29 Dec 2025 10:50:07 +0100 Subject: [PATCH 1/2] Add support for triple quoted ASCII byte string --- src/Compiler/lex.fsl | 6 ++++++ .../Conformance/BasicGrammarElements/BasicConstants.fs | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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 From b33e00717a6bf92cb8f2684de7b2bd2053b620c4 Mon Sep 17 00:00:00 2001 From: kerams Date: Mon, 29 Dec 2025 10:59:56 +0100 Subject: [PATCH 2/2] Release notes --- docs/release-notes/.FSharp.Compiler.Service/11.0.0.md | 1 + 1 file changed, 1 insertion(+) 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