From 460f4af2a93460489da608bcf26d34657998a5c0 Mon Sep 17 00:00:00 2001 From: BooksBaum <15612932+Booksbaum@users.noreply.github.com> Date: Tue, 29 Aug 2023 17:11:27 +0200 Subject: [PATCH 01/18] Fix: ASCII byte: Add `\U` & `\x`; Limit Dec range Fix #15867: Add `\U` & `\x` for ASCII Byte Fix #15868: Fix: ASCII Byte Decimal notation accepts value `> 127` --- src/Compiler/lex.fsl | 21 +++- .../LexicalAnalysis/CharByteLiterals.fs | 113 ++++++++++++++++++ .../FSharp.Compiler.ComponentTests.fsproj | 1 + 3 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/CharByteLiterals.fs diff --git a/src/Compiler/lex.fsl b/src/Compiler/lex.fsl index e8edd3086c1..2828a4ba99b 100644 --- a/src/Compiler/lex.fsl +++ b/src/Compiler/lex.fsl @@ -530,11 +530,13 @@ rule token (args: LexArgs) (skip: bool) = parse | '\'' trigraph '\'' 'B' { let s = lexeme lexbuf let x = int32 (trigraph s.[2] s.[3] s.[4]) - if x < 0 || x > 255 then + if x < 0 || x > 127 then fail args lexbuf (FSComp.SR.lexInvalidByteLiteral()) (UINT8(byte 0)) else UINT8 (byte(x)) } + | '\'' unicodeGraphShort '\'' { CHAR (char (int32 (unicodeGraphShort (lexemeTrimBoth lexbuf 3 1)))) } + | '\'' unicodeGraphShort '\'' 'B' { let x = int32 (unicodeGraphShort (lexemeTrimBoth lexbuf 3 2)) if x < 0 || x > 127 then @@ -544,13 +546,28 @@ rule token (args: LexArgs) (skip: bool) = parse | '\'' hexGraphShort '\'' { CHAR (char (int32 (hexGraphShort (lexemeTrimBoth lexbuf 3 1)))) } - | '\'' unicodeGraphShort '\'' { CHAR (char (int32 (unicodeGraphShort (lexemeTrimBoth lexbuf 3 1)))) } + | '\'' hexGraphShort '\'' 'B' + { let x = int32 (hexGraphShort (lexemeTrimBoth lexbuf 3 2)) + if x < 0 || x > 127 then + fail args lexbuf (FSComp.SR.lexInvalidByteLiteral()) (UINT8(byte 0)) + else + UINT8 (byte(x)) } | '\'' unicodeGraphLong '\'' { match unicodeGraphLong (lexemeTrimBoth lexbuf 3 1) with | SingleChar(c) -> CHAR (char c) | _ -> fail args lexbuf (FSComp.SR.lexThisUnicodeOnlyInStringLiterals()) (CHAR (char 0)) } + | '\'' unicodeGraphLong '\'' 'B' + { match unicodeGraphLong (lexemeTrimBoth lexbuf 3 2) with + | SingleChar(c) -> + let x = int32 c + if x < 0 || x > 127 then + fail args lexbuf (FSComp.SR.lexInvalidByteLiteral()) (UINT8(byte 0)) + else + UINT8 (byte(x)) + | _ -> fail args lexbuf (FSComp.SR.lexInvalidByteLiteral()) (UINT8(byte 0)) } + | "(*IF-FSHARP" { if lexbuf.SupportsFeature LanguageFeature.MLCompatRevisions then mlCompatWarning (FSComp.SR.lexIndentOffForML()) lexbuf.LexemeRange diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/CharByteLiterals.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/CharByteLiterals.fs new file mode 100644 index 00000000000..047c184638a --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/CharByteLiterals.fs @@ -0,0 +1,113 @@ +module Conformance.LexicalAnalysis.CharByteLiterals + +open Xunit +open FSharp.Test.Compiler + +[] +let ``all byte char notations pass type check`` () = + Fs """ +[ + 'a'B + '\097'B + '\x61'B + '\u0061'B + '\U00000061'B +] +|> ignore + """ + |> typecheck + |> shouldSucceed + +[] +let ``all byte char notations produce correct value``() = + Fs """ +let chars = [ + 'a'B + '\097'B + '\x61'B + '\u0061'B + '\U00000061'B +] +let expected = 97uy +chars +|> List.iteri (fun i actual -> if actual <> expected then failwithf "[%i]: Expected %A, but was %A" i expected actual) + """ + |> compileExeAndRun + |> shouldSucceed + +[] +let ``byte value > 128uy fails in all char notations``() = + Fs """ +[ + 'ú'B + '\250'B + '\xFA'B + '\u00FA'B + '\U000000FA'B +] +|> ignore + """ + |> typecheck + |> withDiagnostics [ + (Error 1157, Line 3, Col 5, Line 3, Col 9, "This is not a valid byte literal") + (Error 1157, Line 4, Col 5, Line 4, Col 12, "This is not a valid byte literal") + (Error 1157, Line 5, Col 5, Line 5, Col 12, "This is not a valid byte literal") + (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid byte literal") + (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid byte literal") + ] + +[] +let ``127uy typechecks in char notations``() = + Fs """ +[ + // DELETE -> no direct char representation + '\127'B + '\x7F'B + '\u007F'B + '\U0000007F'B +] +|> ignore + """ + |> typecheck + |> shouldSucceed +[] +let ``128uy fails typecheck in char notations``() = + Fs """ +[ + // Padding Character -> no direct char representation + '\128'B + '\x80'B + '\u0080'B + '\U00000080'B +] +|> ignore + """ + |> typecheck + |> withDiagnostics [ + + (Error 1157, Line 4, Col 5, Line 4, Col 12, "This is not a valid byte literal") + (Error 1157, Line 5, Col 5, Line 5, Col 12, "This is not a valid byte literal") + (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid byte literal") + (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid byte literal") + ] + +[] +let ``value out of byte range fails in char notations``() = + Fs """ +[ + 'β'B + '\946'B + // requires more than 2 digits -> no decimal representation + '\u03B2'B + '\U000003B2'B +] +|> ignore + """ + |> typecheck + |> withDiagnostics [ + (Error 1157, Line 3, Col 5, Line 3, Col 9, "This is not a valid byte literal") + (Error 1157, Line 4, Col 5, Line 4, Col 12, "This is not a valid byte literal") + + (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid byte literal") + (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid byte literal") + ] diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 111ba0c94e5..8216564e9d2 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -86,6 +86,7 @@ + From 0f740cb21b1c0e765559ba68a240f9e0c21c3636 Mon Sep 17 00:00:00 2001 From: BooksBaum <15612932+Booksbaum@users.noreply.github.com> Date: Tue, 29 Aug 2023 11:43:40 +0200 Subject: [PATCH 02/18] Fix #15869: Decimal char in String can be `> 255` Note: Values between `128` and `255` are still valid in Byte String Array (-> several tests in `ByteStrings` fail) --- src/Compiler/lex.fsl | 15 +++-- .../LexicalAnalysis/ByteStrings.fs | 67 +++++++++++++++++++ .../Conformance/LexicalAnalysis/Strings.fs | 40 +++++++++++ .../FSharp.Compiler.ComponentTests.fsproj | 2 + 4 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/ByteStrings.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/Strings.fs diff --git a/src/Compiler/lex.fsl b/src/Compiler/lex.fsl index 2828a4ba99b..953fbb44346 100644 --- a/src/Compiler/lex.fsl +++ b/src/Compiler/lex.fsl @@ -1202,11 +1202,18 @@ and singleQuoteString (sargs: LexerStringArgs) (skip: bool) = parse | trigraph { let (buf, _fin, m, kind, args) = sargs let s = lexeme lexbuf - addByteChar buf (trigraph s.[1] s.[2] s.[3]) - if not skip then - STRING_TEXT (LexCont.String(args.ifdefStack, args.stringNest, LexerStringStyle.SingleQuote, kind, args.interpolationDelimiterLength, m)) + let result() = + if not skip then + STRING_TEXT (LexCont.String(args.ifdefStack, args.stringNest, LexerStringStyle.SingleQuote, kind, args.interpolationDelimiterLength, m)) + else + singleQuoteString sargs skip lexbuf + let c = trigraph s.[1] s.[2] s.[3] + let x = int c + if x < 0 || x > 255 then + fail args lexbuf (FSComp.SR.lexInvalidCharLiteral()) (result()) else - singleQuoteString sargs skip lexbuf } + addByteChar buf c + result() } | hexGraphShort { let (buf, _fin, m, kind, args) = sargs diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/ByteStrings.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/ByteStrings.fs new file mode 100644 index 00000000000..4a9d833550a --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/ByteStrings.fs @@ -0,0 +1,67 @@ +module Conformance.LexicalAnalysis.ByteStrings + +open Xunit +open FSharp.Test.Compiler + +[] +let ``Decimal char > 255 is not valid``() = + Fs """ +// Ω +let _ = "\937"B + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 1158, Line 3, Col 9, Line 3, Col 16, "This is not a valid character literal") + ] + +[] +let ``Decimal char between 128 and 256 is not valid``() = + Fs """ +// ú +let _ = "\250"B + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 1157, Line 3, Col 9, Line 3, Col 16, "This is not a valid byte literal") + ] + +[] +let ``Decimal char < 128 is valid``() = + Fs """ +let _ = "a\097"B + """ + |> typecheck + |> shouldSucceed + +[] +let ``In verbatim string: \937 is valid and not parsed as single char``() = + Fs """ +if @"\937"B <> "\\937"B then failwith "should not be trigraph" + """ + |> compileExeAndRun + |> shouldSucceed + + +[] +let ``values in different notations are invalid above 127``() = + Fs """ +[ + "ú"B + "\128"B + "\x80"B + "\u0080"B + "\U00000080"B +] +|> ignore + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 1157, Line 3, Col 5, Line 3, Col 9, "This is not a valid byte literal") + (Error 1157, Line 4, Col 5, Line 4, Col 12, "This is not a valid byte literal") + (Error 1157, Line 5, Col 5, Line 5, Col 12, "This is not a valid byte literal") + (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid byte literal") + (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid byte literal") + ] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/Strings.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/Strings.fs new file mode 100644 index 00000000000..848a209fca5 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/Strings.fs @@ -0,0 +1,40 @@ +module Conformance.LexicalAnalysis.Strings + +open Xunit +open FSharp.Test.Compiler + +[] +let ``Decimal char > 255 is not valid``() = + Fs """ +printfn "Ω\937" + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + // Note: Error spans full string -- not just error part + (Error 1158, Line 2, Col 9, Line 2, Col 16, "This is not a valid character literal") + ] + +[] +let ``Decimal char between 128 and 256 is valid``() = + Fs """ +printfn "ú\250" + """ + |> typecheck + |> shouldSucceed + +[] +let ``Decimal char < 128 is valid``() = + Fs """ +printfn "a\097" + """ + |> typecheck + |> shouldSucceed + +[] +let ``In verbatim string: \937 is valid and not parsed as single char``() = + Fs """ +if @"\937" <> "\\937" then failwith "should not be trigraph" + """ + |> compileExeAndRun + |> shouldSucceed diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 8216564e9d2..283ce8e9d32 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -87,6 +87,8 @@ + + From 3e954ed4322d459e4bde1fbe01ec811a3849539c Mon Sep 17 00:00:00 2001 From: BooksBaum <15612932+Booksbaum@users.noreply.github.com> Date: Tue, 29 Aug 2023 21:08:52 +0200 Subject: [PATCH 03/18] Enhancement: Mention invalid trigraph in error for string --- src/Compiler/FSComp.txt | 1 + src/Compiler/lex.fsl | 2 +- src/Compiler/xlf/FSComp.txt.cs.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.de.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.es.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.fr.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.it.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.ja.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.ko.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.pl.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.ru.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.tr.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 5 +++++ .../Conformance/LexicalAnalysis/ByteStrings.fs | 2 +- .../Conformance/LexicalAnalysis/Strings.fs | 14 +++++++++++++- 17 files changed, 81 insertions(+), 3 deletions(-) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 9f091d07533..0eff61a6ec2 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1130,6 +1130,7 @@ lexIfOCaml,"IF-FSHARP/IF-CAML regions are no longer supported" 1249,lexUnmatchedRBracesInTripleQuote,"The interpolated string contains unmatched closing braces." 1250,lexTooManyPercentsInTripleQuote,"The interpolated triple quoted string literal does not start with enough '$' characters to allow this many consecutive '%%' characters." 1251,lexExtendedStringInterpolationNotSupported,"Extended string interpolation is not supported in this version of F#." +1252,lexInvalidCharLiteralInString,"'%s' is not a valid character literal" # reshapedmsbuild.fs 1300,toolLocationHelperUnsupportedFrameworkVersion,"The specified .NET Framework version '%s' is not supported. Please specify a value from the enumeration Microsoft.Build.Utilities.TargetDotNetFrameworkVersion." # ----------------------------------------------------------------------------- diff --git a/src/Compiler/lex.fsl b/src/Compiler/lex.fsl index 953fbb44346..f1c08df4831 100644 --- a/src/Compiler/lex.fsl +++ b/src/Compiler/lex.fsl @@ -1210,7 +1210,7 @@ and singleQuoteString (sargs: LexerStringArgs) (skip: bool) = parse let c = trigraph s.[1] s.[2] s.[3] let x = int c if x < 0 || x > 255 then - fail args lexbuf (FSComp.SR.lexInvalidCharLiteral()) (result()) + fail args lexbuf (FSComp.SR.lexInvalidCharLiteralInString (s[0..3])) (result()) else addByteChar buf c result() } diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 950c8d3c846..c884892b5d5 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -622,6 +622,11 @@ Oblasti IF-FSHARP/IF-CAML už nejsou podporovány. + + '{0}' is not a valid character literal + '{0}' is not a valid character literal + + This is not a valid identifier This is not a valid identifier diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 228da2df3b1..d84395489b9 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -622,6 +622,11 @@ IF-FSHARP-/IF-CAML-Regionen werden nicht mehr unterstützt + + '{0}' is not a valid character literal + '{0}' is not a valid character literal + + This is not a valid identifier This is not a valid identifier diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 7db7543091d..95e100436e4 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -622,6 +622,11 @@ Ya no se admiten las regiones IF-FSHARP/IF-CAML + + '{0}' is not a valid character literal + '{0}' is not a valid character literal + + This is not a valid identifier This is not a valid identifier diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index a00e94a4d64..af2d56fb639 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -622,6 +622,11 @@ Les régions IF-FSHARP/IF-CAML ne sont plus prises en charge. + + '{0}' is not a valid character literal + '{0}' is not a valid character literal + + This is not a valid identifier This is not a valid identifier diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index a70f3500a2a..1cf0aad7d82 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -622,6 +622,11 @@ Le aree IF-FSHARP/IF-CAML non sono più supportate + + '{0}' is not a valid character literal + '{0}' is not a valid character literal + + This is not a valid identifier This is not a valid identifier diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 85b79f2aa38..7fd303709d3 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -622,6 +622,11 @@ IF-FSHARP/IF-CAML リージョンは現在サポートされていません + + '{0}' is not a valid character literal + '{0}' is not a valid character literal + + This is not a valid identifier This is not a valid identifier diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index fbedcdb01c7..6a16ec761a1 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -622,6 +622,11 @@ IF-FSHARP/IF-CAML 영역은 더 이상 지원되지 않습니다. + + '{0}' is not a valid character literal + '{0}' is not a valid character literal + + This is not a valid identifier This is not a valid identifier diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 7bf3c8187d8..3a13f0298f6 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -622,6 +622,11 @@ Regiony IF-FSHARP/IF-CAML nie są już obsługiwane + + '{0}' is not a valid character literal + '{0}' is not a valid character literal + + This is not a valid identifier This is not a valid identifier diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 5e3a492618d..5a22036edf4 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -622,6 +622,11 @@ As regiões IF-FSHARP/IF-CAML não são mais suportadas + + '{0}' is not a valid character literal + '{0}' is not a valid character literal + + This is not a valid identifier This is not a valid identifier diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 3e50524becd..48cb3b5cf45 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -622,6 +622,11 @@ Регионы IF-FSHARP/IF-CAML больше не поддерживаются + + '{0}' is not a valid character literal + '{0}' is not a valid character literal + + This is not a valid identifier This is not a valid identifier diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 59a6cc71fee..2a683f7c35e 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -622,6 +622,11 @@ IF-FSHARP/IF-CAML bölgeleri artık desteklenmiyor + + '{0}' is not a valid character literal + '{0}' is not a valid character literal + + This is not a valid identifier This is not a valid identifier diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index a836bd75cb1..0fe059f617d 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -622,6 +622,11 @@ 不再支持 IF-FSHARP/IF-CAML 区域 + + '{0}' is not a valid character literal + '{0}' is not a valid character literal + + This is not a valid identifier This is not a valid identifier diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 9b7c435824e..2f704bae916 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -622,6 +622,11 @@ 不再支援 IF-FSHARP/IF-CAML 區域 + + '{0}' is not a valid character literal + '{0}' is not a valid character literal + + This is not a valid identifier This is not a valid identifier diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/ByteStrings.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/ByteStrings.fs index 4a9d833550a..3840e3b1c85 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/ByteStrings.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/ByteStrings.fs @@ -12,7 +12,7 @@ let _ = "\937"B |> typecheck |> shouldFail |> withDiagnostics [ - (Error 1158, Line 3, Col 9, Line 3, Col 16, "This is not a valid character literal") + (Error 1252, Line 3, Col 9, Line 3, Col 16, "'\\937' is not a valid character literal") ] [] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/Strings.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/Strings.fs index 848a209fca5..5e02bccc94a 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/Strings.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/Strings.fs @@ -12,7 +12,7 @@ printfn "Ω\937" |> shouldFail |> withDiagnostics [ // Note: Error spans full string -- not just error part - (Error 1158, Line 2, Col 9, Line 2, Col 16, "This is not a valid character literal") + (Error 1252, Line 2, Col 9, Line 2, Col 16, "'\\937' is not a valid character literal") ] [] @@ -38,3 +38,15 @@ if @"\937" <> "\\937" then failwith "should not be trigraph" """ |> compileExeAndRun |> shouldSucceed + +[] +let ``Error message for invalid decimal char contains only invalid trigraph``() = + Fs """ +printfn "foo\937bar" + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 1252, Line 2, Col 9, Line 2, Col 21, "'\\937' is not a valid character literal") + ] + From 3fb9df700ee0b62f1e07e32a024b558f8707215e Mon Sep 17 00:00:00 2001 From: BooksBaum <15612932+Booksbaum@users.noreply.github.com> Date: Wed, 30 Aug 2023 13:43:15 +0200 Subject: [PATCH 04/18] Fix: Errors for invalid trigraph & `\U` in String span complete string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit prev: ```fsharp > "foo\U12345678bar";; ^^^^^^^^^^^^^^^^^^ stdin(1,1): error FS1245: \U12345678 is not a valid Unicode character escape sequence ``` now: ```fsharp > "foo\U12345678bar";; ----^^^^^^^^^^ stdin(1,5): error FS1245: \U12345678 is not a valid Unicode character escape sequence ``` Note: In Byte Strings that's only the case for invalid chars (-> invalid in normal string too), but not for chars invalid only inside byte string: ```fsharp > "foo\U000003C0bar";; val it: string = "fooπbar" > "foo\U000003C0bar"B;; ^^^^^^^^^^^^^^^^^^^ stdin(8,1): error FS1140: This byte array literal contains characters that do not encode as a single byte ``` Reason: We only now at end of string if it's a Byte String. At this point we don't have direct/simple access to the invalid element (and its notation) any more -> we know the value and can validate it -- but don't know exactly where it's located --- src/Compiler/lex.fsl | 6 +++-- .../LexicalAnalysis/ByteStrings.fs | 22 ++++++++++++++++++- .../Conformance/LexicalAnalysis/Strings.fs | 16 +++++++++++--- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/Compiler/lex.fsl b/src/Compiler/lex.fsl index f1c08df4831..40febf9c732 100644 --- a/src/Compiler/lex.fsl +++ b/src/Compiler/lex.fsl @@ -1210,7 +1210,8 @@ and singleQuoteString (sargs: LexerStringArgs) (skip: bool) = parse let c = trigraph s.[1] s.[2] s.[3] let x = int c if x < 0 || x > 255 then - fail args lexbuf (FSComp.SR.lexInvalidCharLiteralInString (s[0..3])) (result()) + fail args lexbuf (FSComp.SR.lexInvalidCharLiteralInString (s[0..3])) () + result() else addByteChar buf c result() } @@ -1241,7 +1242,8 @@ and singleQuoteString (sargs: LexerStringArgs) (skip: bool) = parse singleQuoteString sargs skip lexbuf match unicodeGraphLong hexChars with | Invalid -> - fail args lexbuf (FSComp.SR.lexInvalidUnicodeLiteral hexChars) (result()) + fail args lexbuf (FSComp.SR.lexInvalidUnicodeLiteral hexChars) () + result() | SingleChar(c) -> addUnicodeChar buf (int c) result() diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/ByteStrings.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/ByteStrings.fs index 3840e3b1c85..f8e3d951aee 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/ByteStrings.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/ByteStrings.fs @@ -12,7 +12,7 @@ let _ = "\937"B |> typecheck |> shouldFail |> withDiagnostics [ - (Error 1252, Line 3, Col 9, Line 3, Col 16, "'\\937' is not a valid character literal") + (Error 1252, Line 3, Col 10, Line 3, Col 14, "'\\937' is not a valid character literal") ] [] @@ -65,3 +65,23 @@ let ``values in different notations are invalid above 127``() = (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid byte literal") (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid byte literal") ] + +[] +let ``Error messages for different notations only span invalid notation``() = + Fs """ +"ok:\061;err:\937;err:\U12345678;err:\U00005678;fin"B +|> printfn "%A" + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 1252, Line 2, Col 14, Line 2, Col 18, "'\\937' is not a valid character literal") + (Error 1245, Line 2, Col 23, Line 2, Col 33, "\\U12345678 is not a valid Unicode character escape sequence") + + // Note: Error for `\U00005678` spans full byte string: + // Is a valid char, but two bytes -> not valid inside byte string + // But check for correct byte happens after string is finished + // (because `B` suffix -> only know at end if it's a byte string) + // -> Don't have direct access to range of invalid char any more + (Error 1140, Line 2, Col 1, Line 2, Col 54, "This byte array literal contains characters that do not encode as a single byte") + ] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/Strings.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/Strings.fs index 5e02bccc94a..f605aef9a5e 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/Strings.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/Strings.fs @@ -11,8 +11,7 @@ printfn "Ω\937" |> typecheck |> shouldFail |> withDiagnostics [ - // Note: Error spans full string -- not just error part - (Error 1252, Line 2, Col 9, Line 2, Col 16, "'\\937' is not a valid character literal") + (Error 1252, Line 2, Col 11, Line 2, Col 15, "'\\937' is not a valid character literal") ] [] @@ -47,6 +46,17 @@ printfn "foo\937bar" |> typecheck |> shouldFail |> withDiagnostics [ - (Error 1252, Line 2, Col 9, Line 2, Col 21, "'\\937' is not a valid character literal") + (Error 1252, Line 2, Col 13, Line 2, Col 17, "'\\937' is not a valid character literal") ] +[] +let ``Error messages for different notations only span invalid notation``() = + Fs """ +printfn "ok:\061;err:\937;err:\U12345678;ok:\U00005678;fin" + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 1252, Line 2, Col 22, Line 2, Col 26, "'\\937' is not a valid character literal") + (Error 1245, Line 2, Col 31, Line 2, Col 41, "\\U12345678 is not a valid Unicode character escape sequence") + ] From 9ce73bb2f8b337e85c4805521483aea896372e01 Mon Sep 17 00:00:00 2001 From: BooksBaum <15612932+Booksbaum@users.noreply.github.com> Date: Thu, 7 Sep 2023 12:49:58 +0200 Subject: [PATCH 05/18] Update Error Message for ASCII Byte to mention expected Range MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change `Error` to `Warning` for cases current F# succeeds, but are now Error (in prev commits introduced): * Trigraph ASCII Byte when between inside `128..255`: ```fsharp // prev > '\973'B;; ^^^^^^^ stdin(11,1): error FS1157: This is not a valid byte literal > '\250'B;; val it: byte = 250uy // now > '\973'B;; ^^^^^^^ stdin(2,1): error FS1157: This is not a valid ASCII byte literal. Value must be < 128y. > '\250'B;; ^^^^^^^ stdin(3,1): warning FS1157: This is not a valid ASCII byte literal. Value should be < 128y. Note: In a future F# version this Warning will be promoted to Error! val it: byte = 250uy ``` * Trigraph string when `> 255` ```fsharp // prev > "\937";; val it: string = "©" // now > "\937";; -^^^^ stdin(4,2): warning FS1252: '\937' is not a valid character literal. Note: Currently the value is wrapped around byte range to '\169'. In a future F# version this Warning will be promoted to Error! val it: string = "©" ``` Additional for these case: Add Note about Promoting to Error in future F# version -> in `lex.fsl`: `//TODO` with note how to promote to `Error` Note: I changed the message for `lexInvalidByteLiteral` (incl. rename to `lexInvalidAsciiByteLiteral`). `lexInvalidByteLiteral` was previously translated (-> in `FSComp.txt.XXX.xlf` files), but now isn't any more even though most of the message remained the same: * Prev: `This is not a valid byte literal.` * Now: `This is not a valid ASCII byte literal. Value should be < 128y.` --- src/Compiler/FSComp.txt | 5 +-- src/Compiler/lex.fsl | 30 ++++++++++++----- src/Compiler/xlf/FSComp.txt.cs.xlf | 19 +++++++---- src/Compiler/xlf/FSComp.txt.de.xlf | 19 +++++++---- src/Compiler/xlf/FSComp.txt.es.xlf | 19 +++++++---- src/Compiler/xlf/FSComp.txt.fr.xlf | 19 +++++++---- src/Compiler/xlf/FSComp.txt.it.xlf | 19 +++++++---- src/Compiler/xlf/FSComp.txt.ja.xlf | 19 +++++++---- src/Compiler/xlf/FSComp.txt.ko.xlf | 19 +++++++---- src/Compiler/xlf/FSComp.txt.pl.xlf | 19 +++++++---- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 19 +++++++---- src/Compiler/xlf/FSComp.txt.ru.xlf | 19 +++++++---- src/Compiler/xlf/FSComp.txt.tr.xlf | 19 +++++++---- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 19 +++++++---- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 19 +++++++---- .../LexicalAnalysis/ByteStrings.fs | 28 ++++++++-------- .../LexicalAnalysis/CharByteLiterals.fs | 32 +++++++++++-------- .../Conformance/LexicalAnalysis/Strings.fs | 15 +++++---- .../E_ByteCharUnicodeChar01.fs | 2 +- .../StringsAndCharacters/E_ByteChars02.fs | 2 +- 20 files changed, 225 insertions(+), 136 deletions(-) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 0eff61a6ec2..a612bc29ef3 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1036,7 +1036,8 @@ lexUnexpectedChar,"Unexpected character '%s'" 1154,lexOusideDecimal,"This number is outside the allowable range for decimal literals" 1155,lexOusideThirtyTwoBitFloat,"This number is outside the allowable range for 32-bit floats" 1156,lexInvalidNumericLiteral,"This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint)." -1157,lexInvalidByteLiteral,"This is not a valid byte literal" +1157,lexInvalidAsciiByteLiteral,"This is not a valid ASCII byte literal. Value must be < 128y." +1157,lexInvalidTrigraphAsciiByteLiteral,"This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error!" 1158,lexInvalidCharLiteral,"This is not a valid character literal" 1159,lexThisUnicodeOnlyInStringLiterals,"This Unicode encoding is only valid in string literals" 1160,lexTokenReserved,"This token is reserved for future use" @@ -1130,7 +1131,7 @@ lexIfOCaml,"IF-FSHARP/IF-CAML regions are no longer supported" 1249,lexUnmatchedRBracesInTripleQuote,"The interpolated string contains unmatched closing braces." 1250,lexTooManyPercentsInTripleQuote,"The interpolated triple quoted string literal does not start with enough '$' characters to allow this many consecutive '%%' characters." 1251,lexExtendedStringInterpolationNotSupported,"Extended string interpolation is not supported in this version of F#." -1252,lexInvalidCharLiteralInString,"'%s' is not a valid character literal" +1252,lexInvalidCharLiteralInString,"'%s' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '%s'. In a future F# version this Warning will be promoted to Error!" # reshapedmsbuild.fs 1300,toolLocationHelperUnsupportedFrameworkVersion,"The specified .NET Framework version '%s' is not supported. Please specify a value from the enumeration Microsoft.Build.Utilities.TargetDotNetFrameworkVersion." # ----------------------------------------------------------------------------- diff --git a/src/Compiler/lex.fsl b/src/Compiler/lex.fsl index 40febf9c732..307f4749500 100644 --- a/src/Compiler/lex.fsl +++ b/src/Compiler/lex.fsl @@ -514,7 +514,7 @@ rule token (args: LexArgs) (skip: bool) = parse { let s = lexeme lexbuf let x = int32 (if s.[1] = '\\' then escape s.[2] else s.[1]) if x < 0 || x > 127 then - fail args lexbuf (FSComp.SR.lexInvalidByteLiteral()) (UINT8(byte 0)) + fail args lexbuf (FSComp.SR.lexInvalidAsciiByteLiteral()) (UINT8(byte 0)) else UINT8 (byte(x)) } @@ -530,8 +530,15 @@ rule token (args: LexArgs) (skip: bool) = parse | '\'' trigraph '\'' 'B' { let s = lexeme lexbuf let x = int32 (trigraph s.[2] s.[3] s.[4]) - if x < 0 || x > 127 then - fail args lexbuf (FSComp.SR.lexInvalidByteLiteral()) (UINT8(byte 0)) + if x < 0 || x > 255 then + fail args lexbuf (FSComp.SR.lexInvalidAsciiByteLiteral()) (UINT8(byte 0)) + elif x > 127 then + // TODO: Promote to Error: + // * Adjust range check in `if` above to `x > 127` + // * Remove this `elif` expression + // * Remove `lexInvalidTrigraphAsciiByteLiteral` from `FSComp.txt` + warning (Error(FSComp.SR.lexInvalidTrigraphAsciiByteLiteral(), lexbuf.LexemeRange)) + UINT8 (byte(x)) else UINT8 (byte(x)) } @@ -540,7 +547,7 @@ rule token (args: LexArgs) (skip: bool) = parse | '\'' unicodeGraphShort '\'' 'B' { let x = int32 (unicodeGraphShort (lexemeTrimBoth lexbuf 3 2)) if x < 0 || x > 127 then - fail args lexbuf (FSComp.SR.lexInvalidByteLiteral()) (UINT8(byte 0)) + fail args lexbuf (FSComp.SR.lexInvalidAsciiByteLiteral()) (UINT8(byte 0)) else UINT8 (byte(x)) } @@ -549,7 +556,7 @@ rule token (args: LexArgs) (skip: bool) = parse | '\'' hexGraphShort '\'' 'B' { let x = int32 (hexGraphShort (lexemeTrimBoth lexbuf 3 2)) if x < 0 || x > 127 then - fail args lexbuf (FSComp.SR.lexInvalidByteLiteral()) (UINT8(byte 0)) + fail args lexbuf (FSComp.SR.lexInvalidAsciiByteLiteral()) (UINT8(byte 0)) else UINT8 (byte(x)) } @@ -563,10 +570,10 @@ rule token (args: LexArgs) (skip: bool) = parse | SingleChar(c) -> let x = int32 c if x < 0 || x > 127 then - fail args lexbuf (FSComp.SR.lexInvalidByteLiteral()) (UINT8(byte 0)) + fail args lexbuf (FSComp.SR.lexInvalidAsciiByteLiteral()) (UINT8(byte 0)) else UINT8 (byte(x)) - | _ -> fail args lexbuf (FSComp.SR.lexInvalidByteLiteral()) (UINT8(byte 0)) } + | _ -> fail args lexbuf (FSComp.SR.lexInvalidAsciiByteLiteral()) (UINT8(byte 0)) } | "(*IF-FSHARP" { if lexbuf.SupportsFeature LanguageFeature.MLCompatRevisions then @@ -1210,7 +1217,14 @@ and singleQuoteString (sargs: LexerStringArgs) (skip: bool) = parse let c = trigraph s.[1] s.[2] s.[3] let x = int c if x < 0 || x > 255 then - fail args lexbuf (FSComp.SR.lexInvalidCharLiteralInString (s[0..3])) () + // TODO: Promote to Error: + // * remove `addByteChar ...` + // * remove `warning ...` + // * Adjust `lexInvalidCharLiteralInString` in `FSComp.txt`: remove `Note` (incl. 2nd placeholder) + // * uncomment `fail ...` + addByteChar buf c + warning (Error(FSComp.SR.lexInvalidCharLiteralInString (s[0..3], sprintf "\\%03i" (x % 256)), lexbuf.LexemeRange)) + //fail args lexbuf (FSComp.SR.lexInvalidCharLiteralInString (s[0..3])) () result() else addByteChar buf c diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index c884892b5d5..59a4968819d 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -622,9 +622,14 @@ Oblasti IF-FSHARP/IF-CAML už nejsou podporovány. + + This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid ASCII byte literal. Value must be < 128y. + + - '{0}' is not a valid character literal - '{0}' is not a valid character literal + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! @@ -632,6 +637,11 @@ This is not a valid identifier + + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + + A '}}' character must be escaped (by doubling) in an interpolated string. Znak }} musí být v interpolovaném řetězci uvozený (zdvojeným znakem). @@ -6322,11 +6332,6 @@ Toto není platný číselný literál. Platné číselné literály zahrnují hodnoty 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). - - This is not a valid byte literal - Toto není platný bajtový literál. - - This is not a valid character literal Toto není platný znakový literál. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index d84395489b9..9392b6131c2 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -622,9 +622,14 @@ IF-FSHARP-/IF-CAML-Regionen werden nicht mehr unterstützt + + This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid ASCII byte literal. Value must be < 128y. + + - '{0}' is not a valid character literal - '{0}' is not a valid character literal + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! @@ -632,6 +637,11 @@ This is not a valid identifier + + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + + A '}}' character must be escaped (by doubling) in an interpolated string. Ein }}-Zeichen muss in einer interpolierten Zeichenfolge (durch Verdoppeln) mit Escapezeichen versehen werden. @@ -6322,11 +6332,6 @@ Dies ist kein gültiges numerisches Literal. Unter anderem sind die folgenden numerischen Literale gültig: 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). - - This is not a valid byte literal - Dies ist kein gültiges Byteliteral. - - This is not a valid character literal Dies ist kein gültiges Zeichenliteral. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 95e100436e4..f9af54776ca 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -622,9 +622,14 @@ Ya no se admiten las regiones IF-FSHARP/IF-CAML + + This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid ASCII byte literal. Value must be < 128y. + + - '{0}' is not a valid character literal - '{0}' is not a valid character literal + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! @@ -632,6 +637,11 @@ This is not a valid identifier + + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + + A '}}' character must be escaped (by doubling) in an interpolated string. El carácter "}}" se debe escapar (duplicándose) en las cadenas interpoladas. @@ -6322,11 +6332,6 @@ Este literal numérico no es válido. Entre los literales numéricos válidos se incluyen 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). - - This is not a valid byte literal - Este no es un literal de byte válido. - - This is not a valid character literal Este no es un literal de carácter válido. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index af2d56fb639..2009348491e 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -622,9 +622,14 @@ Les régions IF-FSHARP/IF-CAML ne sont plus prises en charge. + + This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid ASCII byte literal. Value must be < 128y. + + - '{0}' is not a valid character literal - '{0}' is not a valid character literal + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! @@ -632,6 +637,11 @@ This is not a valid identifier + + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + + A '}}' character must be escaped (by doubling) in an interpolated string. Un caractère '}}' doit faire l'objet d'une séquence d'échappement (par doublement) dans une chaîne interpolée. @@ -6322,11 +6332,6 @@ Il ne s’agit pas d’un littéral numérique valide. Les littéraux numériques valides incluent 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1,0 (float/double), 1,0f (float32/single), 1,0 m (décimal), 1I (bigint). - - This is not a valid byte literal - Littéral d'octet non valide - - This is not a valid character literal Littéral de caractère non valide diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 1cf0aad7d82..365966ae4ae 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -622,9 +622,14 @@ Le aree IF-FSHARP/IF-CAML non sono più supportate + + This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid ASCII byte literal. Value must be < 128y. + + - '{0}' is not a valid character literal - '{0}' is not a valid character literal + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! @@ -632,6 +637,11 @@ This is not a valid identifier + + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + + A '}}' character must be escaped (by doubling) in an interpolated string. In una stringa interpolata è necessario specificare il carattere di escape di un carattere '}}' raddoppiandolo. @@ -6322,11 +6332,6 @@ Non è un valore letterale numerico valido. I valori letterali numerici validi includono 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint 32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1,0 (float/double), 1,0f (float32/single), 1,0m (decimale), 1I (bigint). - - This is not a valid byte literal - Valore letterale byte non valido - - This is not a valid character literal Valore letterale carattere non valido diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 7fd303709d3..ac5914a75f9 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -622,9 +622,14 @@ IF-FSHARP/IF-CAML リージョンは現在サポートされていません + + This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid ASCII byte literal. Value must be < 128y. + + - '{0}' is not a valid character literal - '{0}' is not a valid character literal + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! @@ -632,6 +637,11 @@ This is not a valid identifier + + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + + A '}}' character must be escaped (by doubling) in an interpolated string. 文字 '}}' は、補間された文字列内で (二重にすることで) エスケープする必要があります。 @@ -6322,11 +6332,6 @@ これは有効な数値リテラルではありません。有効な数値リテラルには、1、0x1、0o1、 0b1、1l (int/int32)、1u (uint/uint32)、1L (int64)、1UL (uint64)、1s (int16)、1us (uint16)、1y (int8/sbyte)、1uy (uint8/byte)、1.0 (float/double)、1.0f (float32/single)、1.0m (10 進)、1I (bigint)。 - - This is not a valid byte literal - これは有効なバイト リテラルではありません - - This is not a valid character literal これは有効な文字リテラルではありません diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 6a16ec761a1..58733222c4c 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -622,9 +622,14 @@ IF-FSHARP/IF-CAML 영역은 더 이상 지원되지 않습니다. + + This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid ASCII byte literal. Value must be < 128y. + + - '{0}' is not a valid character literal - '{0}' is not a valid character literal + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! @@ -632,6 +637,11 @@ This is not a valid identifier + + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + + A '}}' character must be escaped (by doubling) in an interpolated string. '}}' 문자는 보간된 문자열에서 이중으로 사용하여 이스케이프해야 합니다. @@ -6322,11 +6332,6 @@ 유효한 숫자 리터럴이 아닙니다. 유효한 숫자 리터럴은 1, 0x1, 0o1, 0b1, 1l(int/int32), 1u(uint/uint32), 1L(int64), 1UL(uint64), 1s(int16), 1us(uint16), 1y(int8/)입니다. sbyte), 1uy(uint8/byte), 1.0(float/double), 1.0f(float32/single), 1.0m(decimal), 1I(bigint). - - This is not a valid byte literal - 올바른 바이트 리터럴이 아닙니다. - - This is not a valid character literal 올바른 문자 리터럴이 아닙니다. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 3a13f0298f6..6d4cce18bc2 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -622,9 +622,14 @@ Regiony IF-FSHARP/IF-CAML nie są już obsługiwane + + This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid ASCII byte literal. Value must be < 128y. + + - '{0}' is not a valid character literal - '{0}' is not a valid character literal + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! @@ -632,6 +637,11 @@ This is not a valid identifier + + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + + A '}}' character must be escaped (by doubling) in an interpolated string. W przypadku znaku „}}” należy zastosować ucieczkę (przez wpisanie dwóch takich znaków) w ciągu interpolowanym. @@ -6322,11 +6332,6 @@ To nie jest prawidłowy literał liczbowy. Prawidłowe literały liczbowe to 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/bajt), 1,0 (float/double), 1,0f (float32/single), 1,0 m (dziesiętny), 1I (bigint). - - This is not a valid byte literal - Nie jest to prawidłowy literał bajtowy - - This is not a valid character literal Nie jest to prawidłowy literał znakowy diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 5a22036edf4..ffb5458934a 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -622,9 +622,14 @@ As regiões IF-FSHARP/IF-CAML não são mais suportadas + + This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid ASCII byte literal. Value must be < 128y. + + - '{0}' is not a valid character literal - '{0}' is not a valid character literal + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! @@ -632,6 +637,11 @@ This is not a valid identifier + + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + + A '}}' character must be escaped (by doubling) in an interpolated string. Um caractere ''}}' precisa ser de escape (ao duplicar) em uma cadeia de caracteres interpolada. @@ -6322,11 +6332,6 @@ Este não é um literal numérico válido. Os literais numéricos válidos incluem 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/ sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). - - This is not a valid byte literal - Este não é um literal de byte válido - - This is not a valid character literal Este não é um literal de caractere válido diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 48cb3b5cf45..1e299c8c4a5 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -622,9 +622,14 @@ Регионы IF-FSHARP/IF-CAML больше не поддерживаются + + This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid ASCII byte literal. Value must be < 128y. + + - '{0}' is not a valid character literal - '{0}' is not a valid character literal + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! @@ -632,6 +637,11 @@ This is not a valid identifier + + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + + A '}}' character must be escaped (by doubling) in an interpolated string. Символ "}}" необходимо экранировать (путем дублирования) в интерполированной строке. @@ -6322,11 +6332,6 @@ Это значение не является допустимым числовым литералом. Допустимые числовые литералы: 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1,0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). - - This is not a valid byte literal - Не является допустимым байтовым литералом. - - This is not a valid character literal Не является допустимым символьным литералом. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 2a683f7c35e..e84020ae5d3 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -622,9 +622,14 @@ IF-FSHARP/IF-CAML bölgeleri artık desteklenmiyor + + This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid ASCII byte literal. Value must be < 128y. + + - '{0}' is not a valid character literal - '{0}' is not a valid character literal + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! @@ -632,6 +637,11 @@ This is not a valid identifier + + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + + A '}}' character must be escaped (by doubling) in an interpolated string. Bir '}}' karakteri, düz metin arasına kod eklenmiş bir dizede kaçış dizisi ile (yineleme yapılarak) belirtilir. @@ -6322,11 +6332,6 @@ Bu, geçerli bir sayısal değişmez değer değil. Geçerli sayısal değişmez değerler şunları içerir: 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). - - This is not a valid byte literal - Bu geçerli bir bayt sabit değeri değil - - This is not a valid character literal Bu geçerli bir karakter sabit değeri değil diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 0fe059f617d..d2a6a35aa70 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -622,9 +622,14 @@ 不再支持 IF-FSHARP/IF-CAML 区域 + + This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid ASCII byte literal. Value must be < 128y. + + - '{0}' is not a valid character literal - '{0}' is not a valid character literal + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! @@ -632,6 +637,11 @@ This is not a valid identifier + + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + + A '}}' character must be escaped (by doubling) in an interpolated string. 在内插字符串中,必需对 "}}" 字符进行转义(通过加倍)。 @@ -6322,11 +6332,6 @@ 这不是有效的数值文本。有效数值包括 1、0x1、0o1、0b1、1l (int/int32)、1u (uint/uint32)、1L (int64)、1UL (uint64)、1s (int16)、1us (uint16)、1y (int8/sbyte)、1uy (uint8/byte)、1.0 (float/double)、1.0f (float32/single)、1.0m (decimal)、1I (bigint)。 - - This is not a valid byte literal - 这不是有效的字节文本 - - This is not a valid character literal 这不是有效的字符文本 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 2f704bae916..256059333a8 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -622,9 +622,14 @@ 不再支援 IF-FSHARP/IF-CAML 區域 + + This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid ASCII byte literal. Value must be < 128y. + + - '{0}' is not a valid character literal - '{0}' is not a valid character literal + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! @@ -632,6 +637,11 @@ This is not a valid identifier + + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + + A '}}' character must be escaped (by doubling) in an interpolated string. 在插補字串中,必須將 '}}' 字元逸出 (重複一次)。 @@ -6322,11 +6332,6 @@ 這不是有效的數值常值。有效的數值常值包括 1, 0x1、0o1、0b1、1l (int/int32)、1u (uint/uint32)、1L (int64)、1UL (uint64)、1s (int16)、1us (uint16)、1y (int8/sbyte)、1uy (uint8/byte)、1.0 (float/double)、1.0f (float32/single)、1.0m (decimal)、1I (bigint)。 - - This is not a valid byte literal - 這不是有效的位元組常值 - - This is not a valid character literal 這不是有效的字元常值 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/ByteStrings.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/ByteStrings.fs index f8e3d951aee..eb7e6ffa773 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/ByteStrings.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/ByteStrings.fs @@ -3,6 +3,11 @@ module Conformance.LexicalAnalysis.ByteStrings open Xunit open FSharp.Test.Compiler +/// `'%s' is not a valid character literal.` with note about wrapped value and error soon +let private invalidCharWarningMsg value wrapped = + FSComp.SR.lexInvalidCharLiteralInString (value, wrapped) + |> snd + [] let ``Decimal char > 255 is not valid``() = Fs """ @@ -11,9 +16,7 @@ let _ = "\937"B """ |> typecheck |> shouldFail - |> withDiagnostics [ - (Error 1252, Line 3, Col 10, Line 3, Col 14, "'\\937' is not a valid character literal") - ] + |> withSingleDiagnostic (Warning 1252, Line 3, Col 10, Line 3, Col 14, invalidCharWarningMsg "\\937" "\\169") [] let ``Decimal char between 128 and 256 is not valid``() = @@ -23,9 +26,7 @@ let _ = "\250"B """ |> typecheck |> shouldFail - |> withDiagnostics [ - (Error 1157, Line 3, Col 9, Line 3, Col 16, "This is not a valid byte literal") - ] + |> withSingleDiagnostic (Error 1157, Line 3, Col 9, Line 3, Col 16, "This is not a valid ASCII byte literal. Value must be < 128y.") [] let ``Decimal char < 128 is valid``() = @@ -45,7 +46,7 @@ if @"\937"B <> "\\937"B then failwith "should not be trigraph" [] -let ``values in different notations are invalid above 127``() = +let ``Values in different notations are invalid above 127``() = Fs """ [ "ú"B @@ -59,11 +60,11 @@ let ``values in different notations are invalid above 127``() = |> typecheck |> shouldFail |> withDiagnostics [ - (Error 1157, Line 3, Col 5, Line 3, Col 9, "This is not a valid byte literal") - (Error 1157, Line 4, Col 5, Line 4, Col 12, "This is not a valid byte literal") - (Error 1157, Line 5, Col 5, Line 5, Col 12, "This is not a valid byte literal") - (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid byte literal") - (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid byte literal") + (Error 1157, Line 3, Col 5, Line 3, Col 9, "This is not a valid ASCII byte literal. Value must be < 128y.") + (Error 1157, Line 4, Col 5, Line 4, Col 12, "This is not a valid ASCII byte literal. Value must be < 128y.") + (Error 1157, Line 5, Col 5, Line 5, Col 12, "This is not a valid ASCII byte literal. Value must be < 128y.") + (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid ASCII byte literal. Value must be < 128y.") + (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid ASCII byte literal. Value must be < 128y.") ] [] @@ -75,7 +76,6 @@ let ``Error messages for different notations only span invalid notation``() = |> typecheck |> shouldFail |> withDiagnostics [ - (Error 1252, Line 2, Col 14, Line 2, Col 18, "'\\937' is not a valid character literal") (Error 1245, Line 2, Col 23, Line 2, Col 33, "\\U12345678 is not a valid Unicode character escape sequence") // Note: Error for `\U00005678` spans full byte string: @@ -84,4 +84,6 @@ let ``Error messages for different notations only span invalid notation``() = // (because `B` suffix -> only know at end if it's a byte string) // -> Don't have direct access to range of invalid char any more (Error 1140, Line 2, Col 1, Line 2, Col 54, "This byte array literal contains characters that do not encode as a single byte") + + (Warning 1252, Line 2, Col 14, Line 2, Col 18, invalidCharWarningMsg "\\937" "\\169") ] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/CharByteLiterals.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/CharByteLiterals.fs index 047c184638a..e800efe83d3 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/CharByteLiterals.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/CharByteLiterals.fs @@ -3,6 +3,11 @@ module Conformance.LexicalAnalysis.CharByteLiterals open Xunit open FSharp.Test.Compiler +/// `This is not a valid ASCII byte literal. Value should be < 128y.` with note that error soon +let private invalidTrigraphCharWarningMsg = + FSComp.SR.lexInvalidTrigraphAsciiByteLiteral () + |> snd + [] let ``all byte char notations pass type check`` () = Fs """ @@ -49,11 +54,12 @@ let ``byte value > 128uy fails in all char notations``() = """ |> typecheck |> withDiagnostics [ - (Error 1157, Line 3, Col 5, Line 3, Col 9, "This is not a valid byte literal") - (Error 1157, Line 4, Col 5, Line 4, Col 12, "This is not a valid byte literal") - (Error 1157, Line 5, Col 5, Line 5, Col 12, "This is not a valid byte literal") - (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid byte literal") - (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid byte literal") + (Error 1157, Line 3, Col 5, Line 3, Col 9, "This is not a valid ASCII byte literal. Value must be < 128y.") + (Error 1157, Line 5, Col 5, Line 5, Col 12, "This is not a valid ASCII byte literal. Value must be < 128y.") + (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid ASCII byte literal. Value must be < 128y.") + (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid ASCII byte literal. Value must be < 128y.") + + (Warning 1157, Line 4, Col 5, Line 4, Col 12, invalidTrigraphCharWarningMsg) ] [] @@ -84,11 +90,11 @@ let ``128uy fails typecheck in char notations``() = """ |> typecheck |> withDiagnostics [ + (Error 1157, Line 5, Col 5, Line 5, Col 12, "This is not a valid ASCII byte literal. Value must be < 128y.") + (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid ASCII byte literal. Value must be < 128y.") + (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid ASCII byte literal. Value must be < 128y.") - (Error 1157, Line 4, Col 5, Line 4, Col 12, "This is not a valid byte literal") - (Error 1157, Line 5, Col 5, Line 5, Col 12, "This is not a valid byte literal") - (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid byte literal") - (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid byte literal") + (Warning 1157, Line 4, Col 5, Line 4, Col 12, invalidTrigraphCharWarningMsg) ] [] @@ -105,9 +111,9 @@ let ``value out of byte range fails in char notations``() = """ |> typecheck |> withDiagnostics [ - (Error 1157, Line 3, Col 5, Line 3, Col 9, "This is not a valid byte literal") - (Error 1157, Line 4, Col 5, Line 4, Col 12, "This is not a valid byte literal") + (Error 1157, Line 3, Col 5, Line 3, Col 9, "This is not a valid ASCII byte literal. Value must be < 128y.") + (Error 1157, Line 4, Col 5, Line 4, Col 12, "This is not a valid ASCII byte literal. Value must be < 128y.") - (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid byte literal") - (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid byte literal") + (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid ASCII byte literal. Value must be < 128y.") + (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid ASCII byte literal. Value must be < 128y.") ] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/Strings.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/Strings.fs index f605aef9a5e..28922805ca3 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/Strings.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/Strings.fs @@ -3,6 +3,11 @@ module Conformance.LexicalAnalysis.Strings open Xunit open FSharp.Test.Compiler +/// `'%s' is not a valid character literal.` with note about wrapped value and error soon +let private invalidCharWarningMsg value wrapped = + FSComp.SR.lexInvalidCharLiteralInString (value, wrapped) + |> snd + [] let ``Decimal char > 255 is not valid``() = Fs """ @@ -10,9 +15,7 @@ printfn "Ω\937" """ |> typecheck |> shouldFail - |> withDiagnostics [ - (Error 1252, Line 2, Col 11, Line 2, Col 15, "'\\937' is not a valid character literal") - ] + |> withSingleDiagnostic (Warning 1252, Line 2, Col 11, Line 2, Col 15, invalidCharWarningMsg "\\937" "\\169") [] let ``Decimal char between 128 and 256 is valid``() = @@ -45,9 +48,7 @@ printfn "foo\937bar" """ |> typecheck |> shouldFail - |> withDiagnostics [ - (Error 1252, Line 2, Col 13, Line 2, Col 17, "'\\937' is not a valid character literal") - ] + |> withSingleDiagnostic (Warning 1252, Line 2, Col 13, Line 2, Col 17, invalidCharWarningMsg "\\937" "\\169") [] let ``Error messages for different notations only span invalid notation``() = @@ -57,6 +58,6 @@ printfn "ok:\061;err:\937;err:\U12345678;ok:\U00005678;fin" |> typecheck |> shouldFail |> withDiagnostics [ - (Error 1252, Line 2, Col 22, Line 2, Col 26, "'\\937' is not a valid character literal") (Error 1245, Line 2, Col 31, Line 2, Col 41, "\\U12345678 is not a valid Unicode character escape sequence") + (Warning 1252, Line 2, Col 22, Line 2, Col 26, invalidCharWarningMsg "\\937" "\\169") ] diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteCharUnicodeChar01.fs b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteCharUnicodeChar01.fs index 1eae16e8719..24be9f48beb 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteCharUnicodeChar01.fs +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteCharUnicodeChar01.fs @@ -4,7 +4,7 @@ // Verify error when trying to take the byte value of // a unicode character literal. -//This is not a valid byte literal +//This is not a valid ASCII byte literal. Value must be < 128y. let _ = '\u2660'B diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteChars02.fs b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteChars02.fs index 0f5b773a644..483d59ddb7e 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteChars02.fs +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteChars02.fs @@ -2,7 +2,7 @@ // Verify getting the byte value of a char works past the first 128 ASCII characters // It is not valid because it must be <= 127 -//This is not a valid byte literal +//This is not a valid ASCII byte literal. Value must be < 128y. if 'ú'B <> 250uy then exit 1 From 90f0111c6dc31446a446310f0b9bf0fd9793a021 Mon Sep 17 00:00:00 2001 From: BooksBaum <15612932+Booksbaum@users.noreply.github.com> Date: Fri, 6 Oct 2023 19:17:04 +0200 Subject: [PATCH 06/18] Emit `Warning` for Byte String Chars > 127 but < 256 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit >= 256 (more than 1 byte) are already an error ```fsharp let _ = "ä"B // ^^^^ // This byte array literal contains 1 non-ASCII characters. All characters should be < 128y. // Note: In future F# versions this Warning might be promoted to Error! ``` Note: Issue with trigraph and > 255: ```fsharp let _ = "\973"B // ^^^^ // Warning: '\973' is not a valid character literal. // Note: Currently the value is wrapped around byte range to '\169' [...] // // ^^^^^^^ // Warning: This byte array literal contains 1 non-ASCII characters. ``` -> Two warnings for same trigraph: * Warning for trigraph `\973` > 255. Detected while parsing trigraph. Don't know yet if String or Byte String. * warning spans just trigraph * Warning for wrapped value `\169` > 127. Detected while checking Byte String for correct values. Don't have any infos about value (range & notation) any more. * warning spans full byte string -> Each Warning is emitted in a different parsing steps. -> No easy way to reduce to just one warning. However: Both warnings are correct and warn about a different issues (albeit in same value) And: should get automatically reduced once out-of-trigraph-range gets promoted to error **Enhancement**: Count number of invalid chars (2-bytes, >128) in byte array ```fsharp let _ = "ΩäΩüΩ"B ``` * prev: `This byte array literal contains characters that do not encode as a single byte` * now: `This byte array literal contains 3 characters that do not encode as a single byte` && `This byte array literal contains 2 non-ASCII characters. All characters should be < 128y.` Note: When checking valid bytes in Byte String, there's no direct mapping to range and notation any more. -> cannot highlight exact byte string part, but only full byte string. * Possible Enhancement?: List invalid chars in a certain notation? For example in `\u` notation. * Pro: * Gives an idea which chars are incorrect * Con: * Might be difficult to process by user because output might be different notation than written in string * Might be a long list with invalid chars --- src/Compiler/FSComp.txt | 3 +- src/Compiler/SyntaxTree/LexHelpers.fs | 23 +++++-- src/Compiler/SyntaxTree/LexHelpers.fsi | 4 +- src/Compiler/lex.fsl | 10 ++- src/Compiler/xlf/FSComp.txt.cs.xlf | 9 ++- src/Compiler/xlf/FSComp.txt.de.xlf | 9 ++- src/Compiler/xlf/FSComp.txt.es.xlf | 9 ++- src/Compiler/xlf/FSComp.txt.fr.xlf | 9 ++- src/Compiler/xlf/FSComp.txt.it.xlf | 9 ++- src/Compiler/xlf/FSComp.txt.ja.xlf | 9 ++- src/Compiler/xlf/FSComp.txt.ko.xlf | 9 ++- src/Compiler/xlf/FSComp.txt.pl.xlf | 9 ++- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 9 ++- src/Compiler/xlf/FSComp.txt.ru.xlf | 9 ++- src/Compiler/xlf/FSComp.txt.tr.xlf | 9 ++- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 9 ++- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 9 ++- .../LexicalAnalysis/ByteStrings.fs | 66 +++++++++++++++---- 18 files changed, 177 insertions(+), 46 deletions(-) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index a612bc29ef3..cd912f54d19 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1019,7 +1019,7 @@ lexfltSeparatorTokensOfPatternMatchMisaligned,"The '|' tokens separating rules o # ----------------------------------------------------------------------------- lexCharNotAllowedInOperatorNames,"'%s' is not permitted as a character in operator names and is reserved for future use" lexUnexpectedChar,"Unexpected character '%s'" -1140,lexByteArrayCannotEncode,"This byte array literal contains characters that do not encode as a single byte" +1140,lexByteArrayCannotEncode,"This byte array literal contains %d characters that do not encode as a single byte" 1141,lexIdentEndInMarkReserved,"Identifiers followed by '%s' are reserved for future use" 1142,lexOutsideEightBitSigned,"This number is outside the allowable range for 8-bit signed integers" 1143,lexOutsideEightBitSignedHex,"This number is outside the allowable range for hexadecimal 8-bit signed integers" @@ -1132,6 +1132,7 @@ lexIfOCaml,"IF-FSHARP/IF-CAML regions are no longer supported" 1250,lexTooManyPercentsInTripleQuote,"The interpolated triple quoted string literal does not start with enough '$' characters to allow this many consecutive '%%' characters." 1251,lexExtendedStringInterpolationNotSupported,"Extended string interpolation is not supported in this version of F#." 1252,lexInvalidCharLiteralInString,"'%s' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '%s'. In a future F# version this Warning will be promoted to Error!" +1253,lexByteArrayOutisdeAscii,"This byte array literal contains %d non-ASCII characters. All characters should be < 128y." # reshapedmsbuild.fs 1300,toolLocationHelperUnsupportedFrameworkVersion,"The specified .NET Framework version '%s' is not supported. Please specify a value from the enumeration Microsoft.Build.Utilities.TargetDotNetFrameworkVersion." # ----------------------------------------------------------------------------- diff --git a/src/Compiler/SyntaxTree/LexHelpers.fs b/src/Compiler/SyntaxTree/LexHelpers.fs index 02d4da364d4..31f8589d3dd 100644 --- a/src/Compiler/SyntaxTree/LexHelpers.fs +++ b/src/Compiler/SyntaxTree/LexHelpers.fs @@ -222,16 +222,31 @@ let addUnicodeChar buf c = addIntChar buf (int c) let addByteChar buf (c: char) = addIntChar buf (int32 c % 256) +type LargerThanOneByte = int +type LargerThan127ButInsideByte = int /// Sanity check that high bytes are zeros. Further check each low byte <= 127 -let stringBufferIsBytes (buf: ByteBuffer) = +let errorsInByteStringBuffer (buf: ByteBuffer) = let bytes = buf.AsMemory() - let mutable ok = true + assert(bytes.Length % 2 = 0) + + // Enhancement?: return faulty values? + // But issue: we don't know range of values -> no direct mapping from value to range & notation + + // values with high byte <> 0 + let mutable largerThanOneByteCount = 0 + // values with high byte = 0, but low byte > 127 + let mutable largerThan127ButSingleByteCount = 0 for i = 0 to bytes.Length / 2 - 1 do if bytes.Span[i * 2 + 1] <> 0uy then - ok <- false + largerThanOneByteCount <- largerThanOneByteCount + 1 + elif bytes.Span[i * 2] > 127uy then + largerThan127ButSingleByteCount <- largerThan127ButSingleByteCount + 1 - ok + if largerThanOneByteCount + largerThan127ButSingleByteCount > 0 then + Some (largerThanOneByteCount, largerThan127ButSingleByteCount) + else + None let newline (lexbuf: LexBuffer<_>) = lexbuf.EndPos <- lexbuf.EndPos.NextLine diff --git a/src/Compiler/SyntaxTree/LexHelpers.fsi b/src/Compiler/SyntaxTree/LexHelpers.fsi index 616bfa8a6fd..0ba901a05e0 100644 --- a/src/Compiler/SyntaxTree/LexHelpers.fsi +++ b/src/Compiler/SyntaxTree/LexHelpers.fsi @@ -97,7 +97,9 @@ val stringBufferAsString: ByteBuffer -> string val stringBufferAsBytes: ByteBuffer -> byte[] -val stringBufferIsBytes: ByteBuffer -> bool +type LargerThanOneByte = int +type LargerThan127ButInsideByte = int +val errorsInByteStringBuffer: ByteBuffer -> Option val newline: Lexing.LexBuffer<'a> -> unit diff --git a/src/Compiler/lex.fsl b/src/Compiler/lex.fsl index 307f4749500..abef1681f68 100644 --- a/src/Compiler/lex.fsl +++ b/src/Compiler/lex.fsl @@ -133,10 +133,14 @@ let startString args (lexbuf: UnicodeLexing.Lexbuf) = if kind.IsInterpolated then fail args lexbuf (FSComp.SR.lexByteStringMayNotBeInterpolated()) () BYTEARRAY (Lexhelp.stringBufferAsBytes buf, synByteStringKind, cont) - elif Lexhelp.stringBufferIsBytes buf then - BYTEARRAY (Lexhelp.stringBufferAsBytes buf, synByteStringKind, cont) else - fail args lexbuf (FSComp.SR.lexByteArrayCannotEncode()) () + match Lexhelp.errorsInByteStringBuffer buf with + | Some (largerThanOneByte, largerThan127) -> + if largerThanOneByte > 0 then + fail args lexbuf (FSComp.SR.lexByteArrayCannotEncode(largerThanOneByte)) () + if largerThan127 > 0 then + warning (Error(FSComp.SR.lexByteArrayOutisdeAscii(largerThan127), lexbuf.LexemeRange)) + | None -> () BYTEARRAY (Lexhelp.stringBufferAsBytes buf, synByteStringKind, cont) elif kind.IsInterpolated then let s = Lexhelp.stringBufferAsString buf diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 59a4968819d..b68bc6a593c 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -607,6 +607,11 @@ Used in computation expressions to introduce a looping construct where the condition is the result of another computation expression. + + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + + a byte string may not be interpolated Bajtový řetězec se nedá interpolovat. @@ -6248,8 +6253,8 @@ - This byte array literal contains characters that do not encode as a single byte - Tento literál bajtového pole obsahuje znaky, které se nekódují jako jednobajtové. + This byte array literal contains {0} characters that do not encode as a single byte + This byte array literal contains {0} characters that do not encode as a single byte diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 9392b6131c2..293278ad143 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -607,6 +607,11 @@ Used in computation expressions to introduce a looping construct where the condition is the result of another computation expression. + + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + + a byte string may not be interpolated Eine Bytezeichenfolge darf nicht interpoliert werden. @@ -6248,8 +6253,8 @@ - This byte array literal contains characters that do not encode as a single byte - Dieses Bytearrayliteral enthält Zeichen, die sich nicht als einzelnes Byte codieren lassen. + This byte array literal contains {0} characters that do not encode as a single byte + This byte array literal contains {0} characters that do not encode as a single byte diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index f9af54776ca..112388ddee5 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -607,6 +607,11 @@ Used in computation expressions to introduce a looping construct where the condition is the result of another computation expression. + + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + + a byte string may not be interpolated no se puede interpolar una cadena de bytes @@ -6248,8 +6253,8 @@ - This byte array literal contains characters that do not encode as a single byte - Este literal de matriz de bytes contiene caracteres que no se codifican como un solo byte. + This byte array literal contains {0} characters that do not encode as a single byte + This byte array literal contains {0} characters that do not encode as a single byte diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 2009348491e..b2463ac5de2 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -607,6 +607,11 @@ Used in computation expressions to introduce a looping construct where the condition is the result of another computation expression. + + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + + a byte string may not be interpolated une chaîne d'octets ne peut pas être interpolée @@ -6248,8 +6253,8 @@ - This byte array literal contains characters that do not encode as a single byte - Ce littéral de tableau d'octets contient des caractères qui ne sont pas encodés sous forme d'octet unique + This byte array literal contains {0} characters that do not encode as a single byte + This byte array literal contains {0} characters that do not encode as a single byte diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 365966ae4ae..6f25a55c87d 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -607,6 +607,11 @@ Used in computation expressions to introduce a looping construct where the condition is the result of another computation expression. + + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + + a byte string may not be interpolated non è possibile interpolare una stringa di byte @@ -6248,8 +6253,8 @@ - This byte array literal contains characters that do not encode as a single byte - Questo valore letterale della matrice di byte contiene caratteri non codificabili come singoli byte + This byte array literal contains {0} characters that do not encode as a single byte + This byte array literal contains {0} characters that do not encode as a single byte diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index ac5914a75f9..d10e60f3425 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -607,6 +607,11 @@ Used in computation expressions to introduce a looping construct where the condition is the result of another computation expression. + + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + + a byte string may not be interpolated バイト文字列は補間されていない可能性があります @@ -6248,8 +6253,8 @@ - This byte array literal contains characters that do not encode as a single byte - このバイト配列リテラルには、シングル バイトとしてエンコードされない文字が含まれます + This byte array literal contains {0} characters that do not encode as a single byte + This byte array literal contains {0} characters that do not encode as a single byte diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 58733222c4c..9d99f6a7a43 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -607,6 +607,11 @@ Used in computation expressions to introduce a looping construct where the condition is the result of another computation expression. + + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + + a byte string may not be interpolated 바이트 문자열을 보간하지 못할 수 있습니다. @@ -6248,8 +6253,8 @@ - This byte array literal contains characters that do not encode as a single byte - 이 바이트 배열 리터럴에는 단일 바이트로 인코딩되지 않는 문자가 포함되어 있습니다. + This byte array literal contains {0} characters that do not encode as a single byte + This byte array literal contains {0} characters that do not encode as a single byte diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 6d4cce18bc2..7f012f574cc 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -607,6 +607,11 @@ Used in computation expressions to introduce a looping construct where the condition is the result of another computation expression. + + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + + a byte string may not be interpolated ciąg bajtowy nie może być interpolowany @@ -6248,8 +6253,8 @@ - This byte array literal contains characters that do not encode as a single byte - Ten literał tablicy bajtowej zawiera znaki, które nie są kodowane jako pojedynczy bajt + This byte array literal contains {0} characters that do not encode as a single byte + This byte array literal contains {0} characters that do not encode as a single byte diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index ffb5458934a..006a05f9bff 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -607,6 +607,11 @@ Used in computation expressions to introduce a looping construct where the condition is the result of another computation expression. + + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + + a byte string may not be interpolated uma cadeia de caracteres de byte não pode ser interpolada @@ -6248,8 +6253,8 @@ - This byte array literal contains characters that do not encode as a single byte - Este literal matriz de byte contém caracteres não codificados como um byte simples + This byte array literal contains {0} characters that do not encode as a single byte + This byte array literal contains {0} characters that do not encode as a single byte diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 1e299c8c4a5..b9519091898 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -607,6 +607,11 @@ Used in computation expressions to introduce a looping construct where the condition is the result of another computation expression. + + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + + a byte string may not be interpolated невозможно выполнить интерполяцию для строки байтов @@ -6248,8 +6253,8 @@ - This byte array literal contains characters that do not encode as a single byte - Этот литерал массива байтов содержит знаки, не поддерживающие однобайтовую кодировку + This byte array literal contains {0} characters that do not encode as a single byte + This byte array literal contains {0} characters that do not encode as a single byte diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index e84020ae5d3..b8a519ac38e 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -607,6 +607,11 @@ Used in computation expressions to introduce a looping construct where the condition is the result of another computation expression. + + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + + a byte string may not be interpolated bir bayt dizesi, düz metin arasına kod eklenerek kullanılamaz @@ -6248,8 +6253,8 @@ - This byte array literal contains characters that do not encode as a single byte - Bu bayt dizisi sabit değeri tek bayt olarak kodlanmayan karakterler içeriyor + This byte array literal contains {0} characters that do not encode as a single byte + This byte array literal contains {0} characters that do not encode as a single byte diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index d2a6a35aa70..12f0ed14400 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -607,6 +607,11 @@ Used in computation expressions to introduce a looping construct where the condition is the result of another computation expression. + + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + + a byte string may not be interpolated 不能内插字节字符串 @@ -6248,8 +6253,8 @@ - This byte array literal contains characters that do not encode as a single byte - 此字节数组文本包含不会以单字节形式进行编码的字符 + This byte array literal contains {0} characters that do not encode as a single byte + This byte array literal contains {0} characters that do not encode as a single byte diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 256059333a8..7b11cceae76 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -607,6 +607,11 @@ Used in computation expressions to introduce a looping construct where the condition is the result of another computation expression. + + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + This byte array literal contains {0} non-ASCII characters. All characters should be < 128y. + + a byte string may not be interpolated 位元組字串不能是插補字串 @@ -6248,8 +6253,8 @@ - This byte array literal contains characters that do not encode as a single byte - 這個位元組陣列常值包含不會編碼成單一位元組的字元 + This byte array literal contains {0} characters that do not encode as a single byte + This byte array literal contains {0} characters that do not encode as a single byte diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/ByteStrings.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/ByteStrings.fs index eb7e6ffa773..b3469959680 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/ByteStrings.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/ByteStrings.fs @@ -8,15 +8,25 @@ let private invalidCharWarningMsg value wrapped = FSComp.SR.lexInvalidCharLiteralInString (value, wrapped) |> snd +/// `This byte array literal contains %d characters that do not encode as a single byte` +let private invalidTwoByteErrorMsg count = + FSComp.SR.lexByteArrayCannotEncode (count) + |> snd + +/// `This byte array literal contains %d non-ASCII characters.` +let private invalidAsciiWarningMsg count = + FSComp.SR.lexByteArrayOutisdeAscii (count) + |> snd + [] let ``Decimal char > 255 is not valid``() = Fs """ // Ω -let _ = "\937"B +let _ = "\837"B """ |> typecheck |> shouldFail - |> withSingleDiagnostic (Warning 1252, Line 3, Col 10, Line 3, Col 14, invalidCharWarningMsg "\\937" "\\169") + |> withSingleDiagnostic (Warning 1252, Line 3, Col 10, Line 3, Col 14, invalidCharWarningMsg "\\837" "\\069") [] let ``Decimal char between 128 and 256 is not valid``() = @@ -26,7 +36,7 @@ let _ = "\250"B """ |> typecheck |> shouldFail - |> withSingleDiagnostic (Error 1157, Line 3, Col 9, Line 3, Col 16, "This is not a valid ASCII byte literal. Value must be < 128y.") + |> withSingleDiagnostic (Warning 1253, Line 3, Col 9, Line 3, Col 16, invalidAsciiWarningMsg 1) [] let ``Decimal char < 128 is valid``() = @@ -60,17 +70,17 @@ let ``Values in different notations are invalid above 127``() = |> typecheck |> shouldFail |> withDiagnostics [ - (Error 1157, Line 3, Col 5, Line 3, Col 9, "This is not a valid ASCII byte literal. Value must be < 128y.") - (Error 1157, Line 4, Col 5, Line 4, Col 12, "This is not a valid ASCII byte literal. Value must be < 128y.") - (Error 1157, Line 5, Col 5, Line 5, Col 12, "This is not a valid ASCII byte literal. Value must be < 128y.") - (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid ASCII byte literal. Value must be < 128y.") - (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid ASCII byte literal. Value must be < 128y.") + (Warning 1253, Line 3, Col 5, Line 3, Col 9, invalidAsciiWarningMsg 1) + (Warning 1253, Line 4, Col 5, Line 4, Col 12, invalidAsciiWarningMsg 1) + (Warning 1253, Line 5, Col 5, Line 5, Col 12, invalidAsciiWarningMsg 1) + (Warning 1253, Line 6, Col 5, Line 6, Col 14, invalidAsciiWarningMsg 1) + (Warning 1253, Line 7, Col 5, Line 7, Col 18, invalidAsciiWarningMsg 1) ] [] let ``Error messages for different notations only span invalid notation``() = Fs """ -"ok:\061;err:\937;err:\U12345678;err:\U00005678;fin"B +"ok:\061;err:\837;err:\U12345678;err:\U00005678;fin"B |> printfn "%A" """ |> typecheck @@ -78,12 +88,46 @@ let ``Error messages for different notations only span invalid notation``() = |> withDiagnostics [ (Error 1245, Line 2, Col 23, Line 2, Col 33, "\\U12345678 is not a valid Unicode character escape sequence") + // Note: Error for `\U00005678` spans full byte string: // Is a valid char, but two bytes -> not valid inside byte string // But check for correct byte happens after string is finished // (because `B` suffix -> only know at end if it's a byte string) // -> Don't have direct access to range of invalid char any more - (Error 1140, Line 2, Col 1, Line 2, Col 54, "This byte array literal contains characters that do not encode as a single byte") + (Error 1140, Line 2, Col 1, Line 2, Col 54,invalidTwoByteErrorMsg 1) + + (Warning 1252, Line 2, Col 14, Line 2, Col 18, invalidCharWarningMsg "\\837" "\\069") + ] + +[] +let ``Decimal char > 255 and > 128 after wrapping triggers two diagnostics``() = + // Currently `\937` trigger TWO diags: + // * Invalid trigraph which gets wrapped -> warning spanning just trigraph + // * Wrapped char is still >= 128 (but < 256) -> warning spanning full byte string + // Those two are checked at different locations (trigraph: while parsing trigraph; 2-byte char: after Byte string was parsed) + // with different infos available (trigraph: trigraph, but don't know if string or byte string; 2-byte-char: byte string, but don't know source notation) + // -> both diags get emitted! + // + // Should be resolved once invalid trigraph gets promoted to error. + Fs """ +// Ω +let _ = "\937"B + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 1252, Line 3, Col 10, Line 3, Col 14, invalidCharWarningMsg "\\937" "\\169") + (Warning 1253, Line 3, Col 9, Line 3, Col 16, invalidAsciiWarningMsg 1) + ] - (Warning 1252, Line 2, Col 14, Line 2, Col 18, invalidCharWarningMsg "\\937" "\\169") +[] +let ``Emit both Error and Warning with correct count``() = + Fs """ +let _ = "Ω --- Ω\169 --- Ωä --- Ωü --- Ω"B + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 1140, Line 2, Col 9, Line 2, Col 44,invalidTwoByteErrorMsg 5) + (Warning 1253, Line 2, Col 9, Line 2, Col 44, invalidAsciiWarningMsg 3) ] From 738f563adbc5f13a77f48c6e0778b1fb19828cf0 Mon Sep 17 00:00:00 2001 From: BooksBaum <15612932+Booksbaum@users.noreply.github.com> Date: Sun, 8 Oct 2023 15:47:56 +0200 Subject: [PATCH 07/18] formatting --- src/Compiler/SyntaxTree/LexHelpers.fs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Compiler/SyntaxTree/LexHelpers.fs b/src/Compiler/SyntaxTree/LexHelpers.fs index 31f8589d3dd..4839d23064a 100644 --- a/src/Compiler/SyntaxTree/LexHelpers.fs +++ b/src/Compiler/SyntaxTree/LexHelpers.fs @@ -224,14 +224,15 @@ let addByteChar buf (c: char) = addIntChar buf (int32 c % 256) type LargerThanOneByte = int type LargerThan127ButInsideByte = int + /// Sanity check that high bytes are zeros. Further check each low byte <= 127 let errorsInByteStringBuffer (buf: ByteBuffer) = let bytes = buf.AsMemory() - assert(bytes.Length % 2 = 0) - + assert (bytes.Length % 2 = 0) + // Enhancement?: return faulty values? // But issue: we don't know range of values -> no direct mapping from value to range & notation - + // values with high byte <> 0 let mutable largerThanOneByteCount = 0 // values with high byte = 0, but low byte > 127 @@ -244,7 +245,7 @@ let errorsInByteStringBuffer (buf: ByteBuffer) = largerThan127ButSingleByteCount <- largerThan127ButSingleByteCount + 1 if largerThanOneByteCount + largerThan127ButSingleByteCount > 0 then - Some (largerThanOneByteCount, largerThan127ButSingleByteCount) + Some(largerThanOneByteCount, largerThan127ButSingleByteCount) else None From b7052de35b8c4efd92fee88917d6f18d7f781148 Mon Sep 17 00:00:00 2001 From: BooksBaum <15612932+Booksbaum@users.noreply.github.com> Date: Sun, 8 Oct 2023 16:39:02 +0200 Subject: [PATCH 08/18] Adjust test: Error range is now exact char, not complete string --- .../StringsAndCharacters/E_BogusLongUnicodeEscape.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_BogusLongUnicodeEscape.fs b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_BogusLongUnicodeEscape.fs index 60476dd8679..e2e49154ba6 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_BogusLongUnicodeEscape.fs +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_BogusLongUnicodeEscape.fs @@ -10,5 +10,5 @@ let bogusString02 = "\UFFFF0000" exit 1 //This Unicode encoding is only valid in string literals -//\\U00110000 is not a valid Unicode character escape sequence -//\\UFFFF0000 is not a valid Unicode character escape sequence +//\\U00110000 is not a valid Unicode character escape sequence +//\\UFFFF0000 is not a valid Unicode character escape sequence From 1009d6f656179016f56f7a58f5b8c34e82476275 Mon Sep 17 00:00:00 2001 From: BooksBaum <15612932+Booksbaum@users.noreply.github.com> Date: Sun, 8 Oct 2023 16:39:48 +0200 Subject: [PATCH 09/18] Adjust test: Error msg now contains number of invalid chars --- .../StringsAndCharacters/E_ByteStrUnicodeChar01.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteStrUnicodeChar01.fs b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteStrUnicodeChar01.fs index a921681d40a..5ef49323688 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteStrUnicodeChar01.fs +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteStrUnicodeChar01.fs @@ -4,7 +4,7 @@ // Verify error when trying to take the byte string of // a string literal with unicode characters -//This byte array literal contains characters that do not encode as a single byte +//This byte array literal contains 1 characters that do not encode as a single byte let _ = "\u2660"B From 63c4c9fd76488793becd6bdf5e1eefca0d53b2b3 Mon Sep 17 00:00:00 2001 From: Petr Date: Mon, 19 Aug 2024 17:32:05 +0200 Subject: [PATCH 10/18] Update src/Compiler/FSComp.txt Co-authored-by: Brian Rourke Boll --- src/Compiler/FSComp.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 58e850bea45..4729addd75e 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1037,7 +1037,7 @@ lexUnexpectedChar,"Unexpected character '%s'" 1154,lexOutsideDecimal,"This number is outside the allowable range for decimal literals" 1155,lexOutsideThirtyTwoBitFloat,"This number is outside the allowable range for 32-bit floats" 1156,lexInvalidNumericLiteral,"This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint)." -1157,lexInvalidAsciiByteLiteral,"This is not a valid ASCII byte literal. Value must be < 128y." +1157,lexInvalidAsciiByteLiteral,"This is not a valid byte character literal. The value must be less than or equal to '\\127'B." 1157,lexInvalidTrigraphAsciiByteLiteral,"This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error!" 1158,lexInvalidCharLiteral,"This is not a valid character literal" 1159,lexThisUnicodeOnlyInStringLiterals,"This Unicode encoding is only valid in string literals" From 84c4dfce5c781be505abbccad0fef54f82ab3235 Mon Sep 17 00:00:00 2001 From: Petr Date: Mon, 19 Aug 2024 17:33:29 +0200 Subject: [PATCH 11/18] Update FSComp.txt --- src/Compiler/FSComp.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 4729addd75e..25133a8f9ca 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1038,7 +1038,7 @@ lexUnexpectedChar,"Unexpected character '%s'" 1155,lexOutsideThirtyTwoBitFloat,"This number is outside the allowable range for 32-bit floats" 1156,lexInvalidNumericLiteral,"This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint)." 1157,lexInvalidAsciiByteLiteral,"This is not a valid byte character literal. The value must be less than or equal to '\\127'B." -1157,lexInvalidTrigraphAsciiByteLiteral,"This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error!" +1157,lexInvalidTrigraphAsciiByteLiteral,"This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error." 1158,lexInvalidCharLiteral,"This is not a valid character literal" 1159,lexThisUnicodeOnlyInStringLiterals,"This Unicode encoding is only valid in string literals" 1160,lexTokenReserved,"This token is reserved for future use" From 9c06eb393992e1a93e34d3221be825a9b86ba84a Mon Sep 17 00:00:00 2001 From: Petr Date: Mon, 19 Aug 2024 17:34:21 +0200 Subject: [PATCH 12/18] Update FSComp.txt --- src/Compiler/FSComp.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 25133a8f9ca..5bb621139fc 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1132,7 +1132,7 @@ lexIfOCaml,"IF-FSHARP/IF-CAML regions are no longer supported" 1249,lexUnmatchedRBracesInTripleQuote,"The interpolated string contains unmatched closing braces." 1250,lexTooManyPercentsInTripleQuote,"The interpolated triple quoted string literal does not start with enough '$' characters to allow this many consecutive '%%' characters." 1251,lexExtendedStringInterpolationNotSupported,"Extended string interpolation is not supported in this version of F#." -1252,lexInvalidCharLiteralInString,"'%s' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '%s'. In a future F# version this Warning will be promoted to Error!" +1252,lexInvalidCharLiteralInString,"'%s' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '%s'. In a future F# version this warning will be promoted to an error." 1253,lexByteArrayOutisdeAscii,"This byte array literal contains %d non-ASCII characters. All characters should be < 128y." # reshapedmsbuild.fs 1300,toolLocationHelperUnsupportedFrameworkVersion,"The specified .NET Framework version '%s' is not supported. Please specify a value from the enumeration Microsoft.Build.Utilities.TargetDotNetFrameworkVersion." From abf48a69c3776f675ccf9d789c9a507686f54fb8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 15:37:58 +0000 Subject: [PATCH 13/18] Automated command ran: xlf Co-authored-by: psfinaki <5451366+psfinaki@users.noreply.github.com> --- src/Compiler/xlf/FSComp.txt.cs.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.de.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.es.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.fr.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.it.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.ja.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.ko.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.pl.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.ru.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.tr.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 12 ++++++------ src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 12 ++++++------ 13 files changed, 78 insertions(+), 78 deletions(-) diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 36f8f61d5e7..96cfe1ddf4f 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -758,13 +758,13 @@ - This is not a valid ASCII byte literal. Value must be < 128y. - This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. @@ -773,8 +773,8 @@ - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 3555fc26608..15221c065cc 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -758,13 +758,13 @@ - This is not a valid ASCII byte literal. Value must be < 128y. - This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. @@ -773,8 +773,8 @@ - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index c33fd95fbeb..e37c6e3b782 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -758,13 +758,13 @@ - This is not a valid ASCII byte literal. Value must be < 128y. - This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. @@ -773,8 +773,8 @@ - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 7c284de4f8d..8b80fbcb887 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -758,13 +758,13 @@ - This is not a valid ASCII byte literal. Value must be < 128y. - This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. @@ -773,8 +773,8 @@ - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 283b3843ddb..bdea9ce59da 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -758,13 +758,13 @@ - This is not a valid ASCII byte literal. Value must be < 128y. - This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. @@ -773,8 +773,8 @@ - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index b9057687d03..a916242ea66 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -758,13 +758,13 @@ - This is not a valid ASCII byte literal. Value must be < 128y. - This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. @@ -773,8 +773,8 @@ - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 02cb1d958bc..686adb6ec39 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -758,13 +758,13 @@ - This is not a valid ASCII byte literal. Value must be < 128y. - This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. @@ -773,8 +773,8 @@ - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 2ebe5bcf5c1..0abec69684a 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -758,13 +758,13 @@ - This is not a valid ASCII byte literal. Value must be < 128y. - This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. @@ -773,8 +773,8 @@ - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index a8433052e56..2e679d58cef 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -758,13 +758,13 @@ - This is not a valid ASCII byte literal. Value must be < 128y. - This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. @@ -773,8 +773,8 @@ - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 3b810705cea..ceee378c089 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -758,13 +758,13 @@ - This is not a valid ASCII byte literal. Value must be < 128y. - This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. @@ -773,8 +773,8 @@ - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 69e4ccf7123..fefda1eed95 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -758,13 +758,13 @@ - This is not a valid ASCII byte literal. Value must be < 128y. - This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. @@ -773,8 +773,8 @@ - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index fc717172ed3..9e8a81faef7 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -758,13 +758,13 @@ - This is not a valid ASCII byte literal. Value must be < 128y. - This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. @@ -773,8 +773,8 @@ - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index ddeaee82b4c..f13867db79b 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -758,13 +758,13 @@ - This is not a valid ASCII byte literal. Value must be < 128y. - This is not a valid ASCII byte literal. Value must be < 128y. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! - '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this Warning will be promoted to Error! + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. + '{0}' is not a valid character literal.\nNote: Currently the value is wrapped around byte range to '{1}'. In a future F# version this warning will be promoted to an error. @@ -773,8 +773,8 @@ - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! - This is not a valid ASCII byte literal. Value should be < 128y.\nNote: In a future F# version this Warning will be promoted to Error! + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. From 9038d70deb529f223a35a7417e70b872d97f191f Mon Sep 17 00:00:00 2001 From: Petr Date: Mon, 19 Aug 2024 17:59:14 +0200 Subject: [PATCH 14/18] Update 9.0.100.md --- docs/release-notes/.FSharp.Compiler.Service/9.0.100.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md index 2923079fb88..7f7937390d7 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md @@ -10,6 +10,7 @@ * Fix missing message for type error (FS0001). ([Issue #17373](https://github.com/dotnet/fsharp/issues/17373), [PR #17516](https://github.com/dotnet/fsharp/pull/17516)) * Nullness export - make sure option<> and other UseNullAsTrueValue types are properly annotated as nullable for C# and reflection consumers [PR #17528](https://github.com/dotnet/fsharp/pull/17528) * MethodAccessException on equality comparison of a type private to module. ([Issue #17541](https://github.com/dotnet/fsharp/issues/17541), [PR #17548](https://github.com/dotnet/fsharp/pull/17548)) +* Add missing byte chars notations, enforce limits in decimal notation in byte char & string (Issues [#15867](https://github.com/dotnet/fsharp/issues/15867), [#15868](https://github.com/dotnet/fsharp/issues/15868), [#15869](https://github.com/dotnet/fsharp/issues/15869), [PR #15898](https://github.com/dotnet/fsharp/pull/15898)) ### Added From 84ac97d9efea985e75b7000e4754454a6e2f7a31 Mon Sep 17 00:00:00 2001 From: Petr Date: Mon, 19 Aug 2024 18:39:00 +0200 Subject: [PATCH 15/18] Update CharByteLiterals.fs --- .../LexicalAnalysis/CharByteLiterals.fs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/CharByteLiterals.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/CharByteLiterals.fs index e800efe83d3..ef452df3f68 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/CharByteLiterals.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/CharByteLiterals.fs @@ -54,10 +54,10 @@ let ``byte value > 128uy fails in all char notations``() = """ |> typecheck |> withDiagnostics [ - (Error 1157, Line 3, Col 5, Line 3, Col 9, "This is not a valid ASCII byte literal. Value must be < 128y.") - (Error 1157, Line 5, Col 5, Line 5, Col 12, "This is not a valid ASCII byte literal. Value must be < 128y.") - (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid ASCII byte literal. Value must be < 128y.") - (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid ASCII byte literal. Value must be < 128y.") + (Error 1157, Line 3, Col 5, Line 3, Col 9, "This is not a valid byte character literal. The value must be less than or equal to '\\127'B.") + (Error 1157, Line 5, Col 5, Line 5, Col 12, "This is not a valid byte character literal. The value must be less than or equal to '\\127'B.") + (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid byte character literal. The value must be less than or equal to '\\127'B.") + (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid byte character literal. The value must be less than or equal to '\\127'B.") (Warning 1157, Line 4, Col 5, Line 4, Col 12, invalidTrigraphCharWarningMsg) ] @@ -90,9 +90,9 @@ let ``128uy fails typecheck in char notations``() = """ |> typecheck |> withDiagnostics [ - (Error 1157, Line 5, Col 5, Line 5, Col 12, "This is not a valid ASCII byte literal. Value must be < 128y.") - (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid ASCII byte literal. Value must be < 128y.") - (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid ASCII byte literal. Value must be < 128y.") + (Error 1157, Line 5, Col 5, Line 5, Col 12, "This is not a valid byte character literal. The value must be less than or equal to '\127'B.") + (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid byte character literal. The value must be less than or equal to '\127'B.") + (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid byte character literal. The value must be less than or equal to '\127'B.") (Warning 1157, Line 4, Col 5, Line 4, Col 12, invalidTrigraphCharWarningMsg) ] @@ -111,9 +111,9 @@ let ``value out of byte range fails in char notations``() = """ |> typecheck |> withDiagnostics [ - (Error 1157, Line 3, Col 5, Line 3, Col 9, "This is not a valid ASCII byte literal. Value must be < 128y.") - (Error 1157, Line 4, Col 5, Line 4, Col 12, "This is not a valid ASCII byte literal. Value must be < 128y.") + (Error 1157, Line 3, Col 5, Line 3, Col 9, "This is not a valid byte character literal. The value must be less than or equal to '\127'B.") + (Error 1157, Line 4, Col 5, Line 4, Col 12, "This is not a valid byte character literal. The value must be less than or equal to '\127'B.") - (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid ASCII byte literal. Value must be < 128y.") - (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid ASCII byte literal. Value must be < 128y.") + (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid byte character literal. The value must be less than or equal to '\127'B.") + (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid byte character literal. The value must be less than or equal to '\127'B.") ] From d4905e1ee31f75bfef16dbc5f632cf9a6b655a9e Mon Sep 17 00:00:00 2001 From: psfinaki Date: Mon, 19 Aug 2024 19:59:00 +0200 Subject: [PATCH 16/18] up --- src/Compiler/FSComp.txt | 4 ++-- src/Compiler/xlf/FSComp.txt.cs.xlf | 8 ++++---- src/Compiler/xlf/FSComp.txt.de.xlf | 8 ++++---- src/Compiler/xlf/FSComp.txt.es.xlf | 8 ++++---- src/Compiler/xlf/FSComp.txt.fr.xlf | 8 ++++---- src/Compiler/xlf/FSComp.txt.it.xlf | 8 ++++---- src/Compiler/xlf/FSComp.txt.ja.xlf | 8 ++++---- src/Compiler/xlf/FSComp.txt.ko.xlf | 8 ++++---- src/Compiler/xlf/FSComp.txt.pl.xlf | 8 ++++---- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 8 ++++---- src/Compiler/xlf/FSComp.txt.ru.xlf | 8 ++++---- src/Compiler/xlf/FSComp.txt.tr.xlf | 8 ++++---- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 8 ++++---- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 8 ++++---- .../LexicalAnalysis/CharByteLiterals.fs | 14 +++++++------- 15 files changed, 61 insertions(+), 61 deletions(-) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 5bb621139fc..8d5475e8326 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1037,8 +1037,8 @@ lexUnexpectedChar,"Unexpected character '%s'" 1154,lexOutsideDecimal,"This number is outside the allowable range for decimal literals" 1155,lexOutsideThirtyTwoBitFloat,"This number is outside the allowable range for 32-bit floats" 1156,lexInvalidNumericLiteral,"This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint)." -1157,lexInvalidAsciiByteLiteral,"This is not a valid byte character literal. The value must be less than or equal to '\\127'B." -1157,lexInvalidTrigraphAsciiByteLiteral,"This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error." +1157,lexInvalidAsciiByteLiteral,"This is not a valid byte character literal. The value must be less than or equal to '\127'B." +1157,lexInvalidTrigraphAsciiByteLiteral,"This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error." 1158,lexInvalidCharLiteral,"This is not a valid character literal" 1159,lexThisUnicodeOnlyInStringLiterals,"This Unicode encoding is only valid in string literals" 1160,lexTokenReserved,"This token is reserved for future use" diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 96cfe1ddf4f..2bfc476c15d 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -758,8 +758,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. @@ -773,8 +773,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 15221c065cc..5bd33d9c781 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -758,8 +758,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. @@ -773,8 +773,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index e37c6e3b782..6be2592f951 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -758,8 +758,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. @@ -773,8 +773,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 8b80fbcb887..a303ecef168 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -758,8 +758,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. @@ -773,8 +773,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index bdea9ce59da..cd2d35cdb15 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -758,8 +758,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. @@ -773,8 +773,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index a916242ea66..fed4bf3e349 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -758,8 +758,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. @@ -773,8 +773,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 686adb6ec39..9c2609d6e32 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -758,8 +758,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. @@ -773,8 +773,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 0abec69684a..47663814082 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -758,8 +758,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. @@ -773,8 +773,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 2e679d58cef..dc8c1670145 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -758,8 +758,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. @@ -773,8 +773,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index ceee378c089..a19c0238a73 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -758,8 +758,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. @@ -773,8 +773,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index fefda1eed95..084de00eaf6 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -758,8 +758,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. @@ -773,8 +773,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 9e8a81faef7..b57d440ed73 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -758,8 +758,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. @@ -773,8 +773,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index f13867db79b..58baa95a307 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -758,8 +758,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. + This is not a valid byte character literal. The value must be less than or equal to '\127'B. @@ -773,8 +773,8 @@ - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. - This is not a valid byte character literal. The value must be less than or equal to '\\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. + This is not a valid byte character literal. The value must be less than or equal to '\127'B.\nNote: In a future F# version this warning will be promoted to an error. diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/CharByteLiterals.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/CharByteLiterals.fs index ef452df3f68..87f895709c7 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/CharByteLiterals.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/CharByteLiterals.fs @@ -90,9 +90,9 @@ let ``128uy fails typecheck in char notations``() = """ |> typecheck |> withDiagnostics [ - (Error 1157, Line 5, Col 5, Line 5, Col 12, "This is not a valid byte character literal. The value must be less than or equal to '\127'B.") - (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid byte character literal. The value must be less than or equal to '\127'B.") - (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid byte character literal. The value must be less than or equal to '\127'B.") + (Error 1157, Line 5, Col 5, Line 5, Col 12, "This is not a valid byte character literal. The value must be less than or equal to '\\127'B.") + (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid byte character literal. The value must be less than or equal to '\\127'B.") + (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid byte character literal. The value must be less than or equal to '\\127'B.") (Warning 1157, Line 4, Col 5, Line 4, Col 12, invalidTrigraphCharWarningMsg) ] @@ -111,9 +111,9 @@ let ``value out of byte range fails in char notations``() = """ |> typecheck |> withDiagnostics [ - (Error 1157, Line 3, Col 5, Line 3, Col 9, "This is not a valid byte character literal. The value must be less than or equal to '\127'B.") - (Error 1157, Line 4, Col 5, Line 4, Col 12, "This is not a valid byte character literal. The value must be less than or equal to '\127'B.") + (Error 1157, Line 3, Col 5, Line 3, Col 9, "This is not a valid byte character literal. The value must be less than or equal to '\\127'B.") + (Error 1157, Line 4, Col 5, Line 4, Col 12, "This is not a valid byte character literal. The value must be less than or equal to '\\127'B.") - (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid byte character literal. The value must be less than or equal to '\127'B.") - (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid byte character literal. The value must be less than or equal to '\127'B.") + (Error 1157, Line 6, Col 5, Line 6, Col 14, "This is not a valid byte character literal. The value must be less than or equal to '\\127'B.") + (Error 1157, Line 7, Col 5, Line 7, Col 18, "This is not a valid byte character literal. The value must be less than or equal to '\\127'B.") ] From babcd570ce9477375fc835832ac33cb6e2a6ca47 Mon Sep 17 00:00:00 2001 From: psfinaki Date: Mon, 19 Aug 2024 22:15:36 +0200 Subject: [PATCH 17/18] up --- .../StringsAndCharacters/E_ByteCharUnicodeChar01.fs | 2 +- .../LexicalAnalysis/StringsAndCharacters/E_ByteChars02.fs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteCharUnicodeChar01.fs b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteCharUnicodeChar01.fs index 24be9f48beb..d61003faecb 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteCharUnicodeChar01.fs +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteCharUnicodeChar01.fs @@ -4,7 +4,7 @@ // Verify error when trying to take the byte value of // a unicode character literal. -//This is not a valid ASCII byte literal. Value must be < 128y. +//This is not a valid byte character literal. The value must be less than or equal to '\127'B. let _ = '\u2660'B diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteChars02.fs b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteChars02.fs index 483d59ddb7e..d29d7079e33 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteChars02.fs +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteChars02.fs @@ -2,7 +2,7 @@ // Verify getting the byte value of a char works past the first 128 ASCII characters // It is not valid because it must be <= 127 -//This is not a valid ASCII byte literal. Value must be < 128y. +//This is not a valid byte character literal. The value must be less than or equal to '\127'B. if 'ú'B <> 250uy then exit 1 From 6057116cda8faab0106db70d5ae427d8a4c18cc4 Mon Sep 17 00:00:00 2001 From: psfinaki Date: Tue, 20 Aug 2024 13:58:23 +0200 Subject: [PATCH 18/18] up --- .../StringsAndCharacters/E_ByteCharUnicodeChar01.fs | 2 +- .../LexicalAnalysis/StringsAndCharacters/E_ByteChars02.fs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteCharUnicodeChar01.fs b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteCharUnicodeChar01.fs index d61003faecb..b07fdbb2586 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteCharUnicodeChar01.fs +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteCharUnicodeChar01.fs @@ -4,7 +4,7 @@ // Verify error when trying to take the byte value of // a unicode character literal. -//This is not a valid byte character literal. The value must be less than or equal to '\127'B. +//This is not a valid byte character literal. The value must be less than or equal to '\\127'B. let _ = '\u2660'B diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteChars02.fs b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteChars02.fs index d29d7079e33..e197d358871 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteChars02.fs +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_ByteChars02.fs @@ -2,7 +2,7 @@ // Verify getting the byte value of a char works past the first 128 ASCII characters // It is not valid because it must be <= 127 -//This is not a valid byte character literal. The value must be less than or equal to '\127'B. +//This is not a valid byte character literal. The value must be less than or equal to '\\127'B. if 'ú'B <> 250uy then exit 1