From e5c3646a96b9478cf7cff418739599a3cd4a6e09 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sat, 8 Oct 2022 16:59:26 +0200 Subject: [PATCH 01/10] Pattern discard not allowed for union case that takes no data --- src/Compiler/Checking/CheckPatterns.fs | 8 ++- .../Checking/PatternMatchCompilation.fs | 1 + .../Checking/PatternMatchCompilation.fsi | 2 + src/Compiler/Driver/CompilerDiagnostics.fs | 8 +++ src/Compiler/FSStrings.resx | 3 + src/Compiler/xlf/FSStrings.cs.xlf | 5 ++ src/Compiler/xlf/FSStrings.de.xlf | 5 ++ src/Compiler/xlf/FSStrings.es.xlf | 5 ++ src/Compiler/xlf/FSStrings.fr.xlf | 5 ++ src/Compiler/xlf/FSStrings.it.xlf | 5 ++ src/Compiler/xlf/FSStrings.ja.xlf | 5 ++ src/Compiler/xlf/FSStrings.ko.xlf | 5 ++ src/Compiler/xlf/FSStrings.pl.xlf | 5 ++ src/Compiler/xlf/FSStrings.pt-BR.xlf | 5 ++ src/Compiler/xlf/FSStrings.ru.xlf | 5 ++ src/Compiler/xlf/FSStrings.tr.xlf | 5 ++ src/Compiler/xlf/FSStrings.zh-Hans.xlf | 5 ++ src/Compiler/xlf/FSStrings.zh-Hant.xlf | 5 ++ .../UnionCasePatternMatchingErrors.fs | 65 ++++++++++++++++++- 19 files changed, 150 insertions(+), 2 deletions(-) diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index 70382723f9..aee2fbb47c 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -7,6 +7,7 @@ module internal FSharp.Compiler.CheckPatterns open System open System.Collections.Generic +open FSharp.Compiler.Text open Internal.Utilities.Library open Internal.Utilities.Library.Extras open FSharp.Compiler.AccessibilityLogic @@ -604,7 +605,12 @@ and TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (m let args, extraPatternsFromNames = match args with - | SynArgPats.Pats args -> args, [] + | SynArgPats.Pats args -> + match args with + | [ SynPat.Wild _ ] when argNames.IsEmpty -> + warning(MatchNotAllowedForUnionCaseWithNoData(m)) + args, [] + | _ -> args, [] | SynArgPats.NamePatPairs (pairs, m, _) -> // rewrite patterns from the form (name-N = pat-N; ...) to (..._, pat-N, _...) // so type T = Case of name: int * value: int diff --git a/src/Compiler/Checking/PatternMatchCompilation.fs b/src/Compiler/Checking/PatternMatchCompilation.fs index 2c53c73202..e5daf0948c 100644 --- a/src/Compiler/Checking/PatternMatchCompilation.fs +++ b/src/Compiler/Checking/PatternMatchCompilation.fs @@ -27,6 +27,7 @@ open FSharp.Compiler.TypeRelations exception MatchIncomplete of bool * (string * bool) option * range exception RuleNeverMatched of range exception EnumMatchIncomplete of bool * (string * bool) option * range +exception MatchNotAllowedForUnionCaseWithNoData of range type ActionOnFailure = | ThrowIncompleteMatchException diff --git a/src/Compiler/Checking/PatternMatchCompilation.fsi b/src/Compiler/Checking/PatternMatchCompilation.fsi index bc52ae8383..5bbc2d3e7b 100644 --- a/src/Compiler/Checking/PatternMatchCompilation.fsi +++ b/src/Compiler/Checking/PatternMatchCompilation.fsi @@ -74,3 +74,5 @@ exception internal MatchIncomplete of bool * (string * bool) option * range exception internal RuleNeverMatched of range exception internal EnumMatchIncomplete of bool * (string * bool) option * range + +exception MatchNotAllowedForUnionCaseWithNoData of range diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index a2fd68372c..a0808d0bf5 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -9,6 +9,7 @@ open System.IO open System.Reflection open System.Text +open FSharp.Compiler.CheckPatterns open Internal.Utilities.Library.Extras open Internal.Utilities.Library open Internal.Utilities.Text @@ -135,6 +136,7 @@ type Exception with | PatternMatchCompilation.MatchIncomplete (_, _, m) | PatternMatchCompilation.EnumMatchIncomplete (_, _, m) | PatternMatchCompilation.RuleNeverMatched m + | PatternMatchCompilation.MatchNotAllowedForUnionCaseWithNoData m | ValNotMutable (_, _, m) | ValNotLocal (_, _, m) | MissingFields (_, m) @@ -239,7 +241,9 @@ type Exception with | NameClash _ -> 23 // 24 cannot be reused | PatternMatchCompilation.MatchIncomplete _ -> 25 + | PatternMatchCompilation.MatchNotAllowedForUnionCaseWithNoData _ | PatternMatchCompilation.RuleNeverMatched _ -> 26 + | ValNotMutable _ -> 27 | ValNotLocal _ -> 28 | MissingFields _ -> 29 @@ -551,6 +555,7 @@ module OldStyleMessages = let MatchIncomplete3E () = Message("MatchIncomplete3", "%s") let MatchIncomplete4E () = Message("MatchIncomplete4", "") let RuleNeverMatchedE () = Message("RuleNeverMatched", "") + let MatchNotAllowedForUnionCaseWithNoDataE () = Message("MatchNotAllowedForUnionCaseWithNoData", "") let EnumMatchIncomplete1E () = Message("EnumMatchIncomplete1", "") let ValNotMutableE () = Message("ValNotMutable", "%s") let ValNotLocalE () = Message("ValNotLocal", "") @@ -1694,6 +1699,9 @@ type Exception with os.AppendString(MatchIncomplete4E().Format) | PatternMatchCompilation.RuleNeverMatched _ -> os.AppendString(RuleNeverMatchedE().Format) + + | PatternMatchCompilation.MatchNotAllowedForUnionCaseWithNoData _ -> + os.AppendString(MatchNotAllowedForUnionCaseWithNoDataE().Format) | ValNotMutable (_, vref, _) -> os.AppendString(ValNotMutableE().Format(vref.DisplayName)) diff --git a/src/Compiler/FSStrings.resx b/src/Compiler/FSStrings.resx index 51f172fbbe..6853139b4e 100644 --- a/src/Compiler/FSStrings.resx +++ b/src/Compiler/FSStrings.resx @@ -1110,4 +1110,7 @@ Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + + Pattern discard not allowed for union case that takes no data. + \ No newline at end of file diff --git a/src/Compiler/xlf/FSStrings.cs.xlf b/src/Compiler/xlf/FSStrings.cs.xlf index f80da09f75..0b9d82804d 100644 --- a/src/Compiler/xlf/FSStrings.cs.xlf +++ b/src/Compiler/xlf/FSStrings.cs.xlf @@ -7,6 +7,11 @@ Nejméně jedna informační zpráva v načteném souboru\n + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.de.xlf b/src/Compiler/xlf/FSStrings.de.xlf index 8978b17675..e5ce71091e 100644 --- a/src/Compiler/xlf/FSStrings.de.xlf +++ b/src/Compiler/xlf/FSStrings.de.xlf @@ -7,6 +7,11 @@ Mindestens eine Informationsmeldung in der geladenen Datei.\n + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.es.xlf b/src/Compiler/xlf/FSStrings.es.xlf index bc0ce4ad5a..79b0d1ef8c 100644 --- a/src/Compiler/xlf/FSStrings.es.xlf +++ b/src/Compiler/xlf/FSStrings.es.xlf @@ -7,6 +7,11 @@ Uno o más mensajes informativos en el archivo cargado.\n + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.fr.xlf b/src/Compiler/xlf/FSStrings.fr.xlf index f88d8e7182..513579ece8 100644 --- a/src/Compiler/xlf/FSStrings.fr.xlf +++ b/src/Compiler/xlf/FSStrings.fr.xlf @@ -7,6 +7,11 @@ Un ou plusieurs messages d’information dans le fichier chargé.\n + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.it.xlf b/src/Compiler/xlf/FSStrings.it.xlf index 90d7b1611f..486594f38c 100644 --- a/src/Compiler/xlf/FSStrings.it.xlf +++ b/src/Compiler/xlf/FSStrings.it.xlf @@ -7,6 +7,11 @@ Uno o più messaggi informativi nel file caricato.\n + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.ja.xlf b/src/Compiler/xlf/FSStrings.ja.xlf index b0a149427b..e94454a448 100644 --- a/src/Compiler/xlf/FSStrings.ja.xlf +++ b/src/Compiler/xlf/FSStrings.ja.xlf @@ -7,6 +7,11 @@ 読み込まれたファイル内の 1 つ以上の情報メッセージ。\n + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.ko.xlf b/src/Compiler/xlf/FSStrings.ko.xlf index 95015040f0..0f91fc636e 100644 --- a/src/Compiler/xlf/FSStrings.ko.xlf +++ b/src/Compiler/xlf/FSStrings.ko.xlf @@ -7,6 +7,11 @@ 로드된 파일에 하나 이상의 정보 메시지가 있습니다.\n + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.pl.xlf b/src/Compiler/xlf/FSStrings.pl.xlf index 48a2f8aded..0d7990b171 100644 --- a/src/Compiler/xlf/FSStrings.pl.xlf +++ b/src/Compiler/xlf/FSStrings.pl.xlf @@ -7,6 +7,11 @@ Jeden lub więcej komunikatów informacyjnych w załadowanym pliku.\n + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.pt-BR.xlf b/src/Compiler/xlf/FSStrings.pt-BR.xlf index 1929c486cd..d412cb996b 100644 --- a/src/Compiler/xlf/FSStrings.pt-BR.xlf +++ b/src/Compiler/xlf/FSStrings.pt-BR.xlf @@ -7,6 +7,11 @@ Uma ou mais mensagens informativas no arquivo carregado.\n + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.ru.xlf b/src/Compiler/xlf/FSStrings.ru.xlf index 1e91c13cd4..f57c99e1d5 100644 --- a/src/Compiler/xlf/FSStrings.ru.xlf +++ b/src/Compiler/xlf/FSStrings.ru.xlf @@ -7,6 +7,11 @@ Одно или несколько информационных сообщений в загруженном файле.\n + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.tr.xlf b/src/Compiler/xlf/FSStrings.tr.xlf index 31b4cad81a..ba262181d2 100644 --- a/src/Compiler/xlf/FSStrings.tr.xlf +++ b/src/Compiler/xlf/FSStrings.tr.xlf @@ -7,6 +7,11 @@ Yüklenen dosyada bir veya daha fazla bilgi mesajı.\n + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.zh-Hans.xlf b/src/Compiler/xlf/FSStrings.zh-Hans.xlf index be3604df4b..c3ea42dc7e 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hans.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hans.xlf @@ -7,6 +7,11 @@ 加载文件 .\n 中有一条或多条信息性消息 + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.zh-Hant.xlf b/src/Compiler/xlf/FSStrings.zh-Hant.xlf index 67e6c25370..dc79e8f7e5 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hant.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hant.xlf @@ -7,6 +7,11 @@ 已載入檔案中的一或多個資訊訊息。\n + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs index b64dff5176..79a3dd538b 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs @@ -69,4 +69,67 @@ let myVal = |> typecheck |> shouldFail |> withSingleDiagnostic (Error 727, Line 10, Col 7, Line 10, Col 15, "This union case expects 3 arguments in tupled form, but was given 2. The missing field arguments may be any of: -\tint") \ No newline at end of file +\tint") + + +[] +let ``Union Pattern discard not allowed for union case that takes no data`` () = + FSharp """ +module Tests +type X = X + +let x: X = X + +let myVal = + match x with + | X _ -> ()""" + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 26, Line 9, Col 7, Line 9, Col 10, "Pattern discard not allowed for union case that takes no data.") + +[] +let ``Pattern discard not allowed for union case that takes no data`` () = + FSharp """ +module Tests +type U = + | A + | B of int * int * int + | C of int * int * int + +let a : U = A + +let myVal = + match a with + | A _ -> 15 + | B (x, _, _) -> 16 + | C _ -> 17""" + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 26, Line 12, Col 7, Line 12, Col 10, "Pattern discard not allowed for union case that takes no data.") + +[] +let ``Multiple pattern discards not allowed for union case that takes no data`` () = + FSharp """ +module Tests +type U = + | A + | B of int * int * int + | C of int * int * int + +type V = + | D + +let a : U = A +let d : V = D + +let myVal = + match a, d with + | A _, D -> 15 + | B (x, _, _), D _ -> 16 + | C _, _ -> 17""" + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 26, Line 16, Col 7, Line 16, Col 10, "Pattern discard not allowed for union case that takes no data.") + (Warning 26, Line 17, Col 20, Line 17, Col 23, "Pattern discard not allowed for union case that takes no data.") + ] \ No newline at end of file From 1a800811c2108d41f6b0a81ea013c42d9350558b Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sat, 8 Oct 2022 23:59:10 +0200 Subject: [PATCH 02/10] Add test for grouped patterns discard --- .../UnionCasePatternMatchingErrors.fs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs index 79a3dd538b..bfdd826c3e 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs @@ -70,8 +70,7 @@ let myVal = |> shouldFail |> withSingleDiagnostic (Error 727, Line 10, Col 7, Line 10, Col 15, "This union case expects 3 arguments in tupled form, but was given 2. The missing field arguments may be any of: \tint") - - + [] let ``Union Pattern discard not allowed for union case that takes no data`` () = FSharp """ @@ -106,7 +105,26 @@ let myVal = |> typecheck |> shouldFail |> withSingleDiagnostic (Warning 26, Line 12, Col 7, Line 12, Col 10, "Pattern discard not allowed for union case that takes no data.") + +[] +let ``Grouped Pattern discard not allowed for union case that takes no data`` () = + FSharp """ +module Tests +type U = + | A + | B of int * int * int + | C of int * int * int +let a : U = A + +let myVal = + match a with + | A _ + | B _ + | C _ -> 17""" + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 26, Line 12, Col 7, Line 12, Col 10, "Pattern discard not allowed for union case that takes no data.") [] let ``Multiple pattern discards not allowed for union case that takes no data`` () = FSharp """ From 43f21c67fb5858825cd836fb40b55a89ada300c9 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sun, 9 Oct 2022 00:00:43 +0200 Subject: [PATCH 03/10] Remove unnecesary use of wildcare across the compiler --- src/Compiler/AbstractIL/il.fs | 2 +- src/Compiler/AbstractIL/ilreflect.fs | 2 +- src/Compiler/Checking/CheckExpressions.fs | 2 +- src/Compiler/Checking/PatternMatchCompilation.fs | 12 ++++++------ src/Compiler/Checking/PostInferenceChecks.fs | 6 +++--- src/Compiler/CodeGen/IlxGen.fs | 6 +++--- src/Compiler/Driver/CompilerDiagnostics.fs | 6 +++--- src/Compiler/Interactive/fsi.fs | 2 +- src/Compiler/Optimize/Optimizer.fs | 2 +- src/Compiler/Service/SemanticClassification.fs | 8 ++++---- src/Compiler/Service/ServiceDeclarationLists.fs | 2 +- src/Compiler/Symbols/Symbols.fs | 2 +- src/Compiler/TypedTree/TypedTreeOps.fs | 6 +++--- tests/FSharp.Test.Utilities/CompilerAssert.fs | 14 +++++++------- tests/service/data/TestTP/ProvidedTypes.fs | 8 ++++---- 15 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/Compiler/AbstractIL/il.fs b/src/Compiler/AbstractIL/il.fs index bbd5183842..e0a5bb576a 100644 --- a/src/Compiler/AbstractIL/il.fs +++ b/src/Compiler/AbstractIL/il.fs @@ -4629,7 +4629,7 @@ let rec encodeCustomAttrElemTypeForObject x = | ILAttribElem.UInt64 _ -> [| et_U8 |] | ILAttribElem.Type _ -> [| 0x50uy |] | ILAttribElem.TypeRef _ -> [| 0x50uy |] - | ILAttribElem.Null _ -> [| et_STRING |] // yes, the 0xe prefix is used when passing a "null" to a property or argument of type "object" here + | ILAttribElem.Null -> [| et_STRING |] // yes, the 0xe prefix is used when passing a "null" to a property or argument of type "object" here | ILAttribElem.Single _ -> [| et_R4 |] | ILAttribElem.Double _ -> [| et_R8 |] | ILAttribElem.Array (elemTy, _) -> [| yield et_SZARRAY; yield! encodeCustomAttrElemType elemTy |] diff --git a/src/Compiler/AbstractIL/ilreflect.fs b/src/Compiler/AbstractIL/ilreflect.fs index 1b30f20529..0fc3e73e24 100644 --- a/src/Compiler/AbstractIL/ilreflect.fs +++ b/src/Compiler/AbstractIL/ilreflect.fs @@ -505,7 +505,7 @@ let convTypeRefAux (cenv: cenv) (tref: ILTypeRef) = match tref.Scope with | ILScopeRef.Assembly asmref -> convResolveAssemblyRef cenv asmref qualifiedName | ILScopeRef.Module _ - | ILScopeRef.Local _ -> + | ILScopeRef.Local -> let typT = Type.GetType qualifiedName match typT with diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index bd675aba27..9e21c43427 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -9905,7 +9905,7 @@ and TcMethodArg cenv env (lambdaPropagationInfo, tpenv) (lambdaPropagationInfoFo let lambdaPropagationInfo = [| for info, argInfo in Array.zip lambdaPropagationInfo lambdaPropagationInfoForArg do match argInfo with - | ArgDoesNotMatch _ -> () + | ArgDoesNotMatch -> () | NoInfo | CallerLambdaHasArgTypes _ -> yield info | CalledArgMatchesType (adjustedCalledArgTy, noEagerConstraintApplication) -> diff --git a/src/Compiler/Checking/PatternMatchCompilation.fs b/src/Compiler/Checking/PatternMatchCompilation.fs index e5daf0948c..194f1e5d94 100644 --- a/src/Compiler/Checking/PatternMatchCompilation.fs +++ b/src/Compiler/Checking/PatternMatchCompilation.fs @@ -649,9 +649,9 @@ let isDiscrimSubsumedBy g amap m discrim taken = match taken, discrim with | DecisionTreeTest.IsInst (_, tgtTy1), DecisionTreeTest.IsInst (_, tgtTy2) -> computeWhatFailingTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 = Implication.Fails - | DecisionTreeTest.IsNull _, DecisionTreeTest.IsInst (_, tgtTy2) -> + | DecisionTreeTest.IsNull, DecisionTreeTest.IsInst (_, tgtTy2) -> computeWhatFailingNullTestImpliesAboutTypeTest g tgtTy2 = Implication.Fails - | DecisionTreeTest.IsInst (_, tgtTy1), DecisionTreeTest.IsNull _ -> + | DecisionTreeTest.IsInst (_, tgtTy1), DecisionTreeTest.IsNull -> computeWhatFailingTypeTestImpliesAboutNullTest g tgtTy1 = Implication.Fails | _ -> false @@ -691,7 +691,7 @@ let discrimWithinSimultaneousClass g amap m discrim prev = // Check that each previous test in the set, if successful, gives some information about this test prev |> List.forall (fun edge -> match edge with - | DecisionTreeTest.IsNull _ -> true + | DecisionTreeTest.IsNull -> true | DecisionTreeTest.IsInst (_, tgtTy1) -> computeWhatSuccessfulTypeTestImpliesAboutNullTest g tgtTy1 <> Implication.Nothing | _ -> false) @@ -699,7 +699,7 @@ let discrimWithinSimultaneousClass g amap m discrim prev = // Check that each previous test in the set, if successful, gives some information about this test prev |> List.forall (fun edge -> match edge with - | DecisionTreeTest.IsNull _ -> true + | DecisionTreeTest.IsNull -> true | DecisionTreeTest.IsInst (_, tgtTy1) -> computeWhatSuccessfulTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 <> Implication.Nothing | _ -> false) @@ -1502,7 +1502,7 @@ let CompilePatternBasic // F# exception definitions are sealed. [] - | DecisionTreeTest.IsNull _ -> + | DecisionTreeTest.IsNull -> match computeWhatSuccessfulNullTestImpliesAboutTypeTest g tgtTy1 with | Implication.Succeeds -> [Frontier (i, newActives, valMap)] | Implication.Fails -> [] @@ -1538,7 +1538,7 @@ let CompilePatternBasic | Implication.Nothing -> [frontier] - | DecisionTreeTest.IsNull _ -> + | DecisionTreeTest.IsNull -> match computeWhatSuccessfulNullTestImpliesAboutTypeTest g tgtTy1 with | Implication.Succeeds -> [Frontier (i, newActives, valMap)] | Implication.Fails -> [] diff --git a/src/Compiler/Checking/PostInferenceChecks.fs b/src/Compiler/Checking/PostInferenceChecks.fs index b4d9acf83f..9338abd28f 100644 --- a/src/Compiler/Checking/PostInferenceChecks.fs +++ b/src/Compiler/Checking/PostInferenceChecks.fs @@ -685,7 +685,7 @@ let CheckTypeInstNoInnerByrefs cenv env m tyargs = /// Applied functions get wrapped in coerce nodes for subsumption coercions let (|OptionalCoerce|) expr = match stripDebugPoints expr with - | Expr.Op (TOp.Coerce _, _, [DebugPoints(Expr.App (f, _, _, [], _), _)], _) -> f + | Expr.Op (TOp.Coerce, _, [DebugPoints(Expr.App (f, _, _, [], _), _)], _) -> f | _ -> expr /// Check an expression doesn't contain a 'reraise' @@ -1539,7 +1539,7 @@ and CheckExprOp cenv env (op, tyargs, args, m) ctxt expr = else { scope = 1; flags = LimitFlags.None } - | TOp.LValueOp (LSet _, vref), _, [arg] -> + | TOp.LValueOp (LSet, vref), _, [arg] -> let isVrefLimited = not (HasLimitFlag LimitFlags.StackReferringSpanLike (GetLimitVal cenv env m vref.Deref)) let isArgLimited = HasLimitFlag LimitFlags.StackReferringSpanLike (CheckExprPermitByRefLike cenv env arg) if isVrefLimited && isArgLimited then @@ -1901,7 +1901,7 @@ and CheckAttribArgExpr cenv env expr = | Const.Double _ | Const.Single _ | Const.Char _ - | Const.Zero _ + | Const.Zero | Const.String _ -> () | _ -> if cenv.reportErrors then diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index 829b7e03d2..382a66e387 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -4150,7 +4150,7 @@ and GenApp (cenv: cenv) cgbuf eenv (f, fty, tyargs, curriedArgs, m) sequel = | Expr.Val (v, _, m), _, [ arg ] when valRefEq g v g.methodhandleof_vref -> let (|OptionalCoerce|) x = match stripDebugPoints x with - | Expr.Op (TOp.Coerce _, _, [ arg ], _) -> arg + | Expr.Op (TOp.Coerce, _, [ arg ], _) -> arg | x -> x let (|OptionalTyapp|) x = @@ -4695,7 +4695,7 @@ and eligibleForFilter (cenv: cenv) expr = | Expr.Op (TOp.UnionCaseFieldGet _, _, _, _) -> true | Expr.Op (TOp.ValFieldGet _, _, _, _) -> true | Expr.Op (TOp.TupleFieldGet _, _, _, _) -> true - | Expr.Op (TOp.Coerce _, _, _, _) -> true + | Expr.Op (TOp.Coerce, _, _, _) -> true | Expr.Val _ -> true | _ -> false @@ -7587,7 +7587,7 @@ and GenDecisionTreeSwitch // Use GenDecisionTreeTest to generate a single test for null (when no box required) where the success // is going to the immediate first node in the tree - | TCase (DecisionTreeTest.IsNull _, (TDSuccess ([], 0) as successTree)) :: rest when + | TCase (DecisionTreeTest.IsNull, (TDSuccess ([], 0) as successTree)) :: rest when rest.Length = (match defaultTargetOpt with | None -> 1 | Some _ -> 0) diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index a0808d0bf5..ad18d9a65a 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -1088,7 +1088,7 @@ type Exception with | Parser.TOKEN_BAR_RBRACK -> SR.GetString("Parser.TOKEN.BAR.RBRACK") | Parser.TOKEN_BAR_RBRACE -> SR.GetString("Parser.TOKEN.BAR.RBRACE") | Parser.TOKEN_GREATER_RBRACK -> SR.GetString("Parser.TOKEN.GREATER.RBRACK") - | Parser.TOKEN_RQUOTE_DOT _ + | Parser.TOKEN_RQUOTE_DOT | Parser.TOKEN_RQUOTE -> SR.GetString("Parser.TOKEN.RQUOTE") | Parser.TOKEN_RBRACK -> SR.GetString("Parser.TOKEN.RBRACK") | Parser.TOKEN_RBRACE @@ -1115,8 +1115,8 @@ type Exception with | Parser.TOKEN_OTHEN -> SR.GetString("Parser.TOKEN.OTHEN") | Parser.TOKEN_ELSE | Parser.TOKEN_OELSE -> SR.GetString("Parser.TOKEN.OELSE") - | Parser.TOKEN_LET _ - | Parser.TOKEN_OLET _ -> SR.GetString("Parser.TOKEN.OLET") + | Parser.TOKEN_LET + | Parser.TOKEN_OLET -> SR.GetString("Parser.TOKEN.OLET") | Parser.TOKEN_OBINDER | Parser.TOKEN_BINDER -> SR.GetString("Parser.TOKEN.BINDER") | Parser.TOKEN_OAND_BANG diff --git a/src/Compiler/Interactive/fsi.fs b/src/Compiler/Interactive/fsi.fs index f4ee6685a1..898f15d884 100644 --- a/src/Compiler/Interactive/fsi.fs +++ b/src/Compiler/Interactive/fsi.fs @@ -279,7 +279,7 @@ type ILMultiInMemoryAssemblyEmitEnv( | ILScopeRef.Assembly asmref -> convResolveAssemblyRef asmref qualifiedName | ILScopeRef.Module _ - | ILScopeRef.Local _ -> + | ILScopeRef.Local -> let typT = Type.GetType qualifiedName match typT with | null -> error(Error(FSComp.SR.itemNotFoundDuringDynamicCodeGen ("type", qualifiedName, ""), range0)) diff --git a/src/Compiler/Optimize/Optimizer.fs b/src/Compiler/Optimize/Optimizer.fs index fa96506920..54665570cc 100644 --- a/src/Compiler/Optimize/Optimizer.fs +++ b/src/Compiler/Optimize/Optimizer.fs @@ -1575,7 +1575,7 @@ let IsKnownOnlyMutableBeforeUse (vref: ValRef) = let IsDiscardableEffectExpr expr = match stripDebugPoints expr with - | Expr.Op (TOp.LValueOp (LByrefGet _, _), [], [], _) -> true + | Expr.Op (TOp.LValueOp (LByrefGet, _), [], [], _) -> true | _ -> false /// Checks is a value binding is non-discardable diff --git a/src/Compiler/Service/SemanticClassification.fs b/src/Compiler/Service/SemanticClassification.fs index 5da02e3209..03e9ce2f67 100644 --- a/src/Compiler/Service/SemanticClassification.fs +++ b/src/Compiler/Service/SemanticClassification.fs @@ -107,7 +107,7 @@ module TcResolutionsExtensions = | TFSharpInterface -> SemanticClassificationType.Interface | TFSharpStruct -> SemanticClassificationType.ValueType | TFSharpDelegate _ -> SemanticClassificationType.Delegate - | TFSharpEnum _ -> SemanticClassificationType.Enumeration + | TFSharpEnum -> SemanticClassificationType.Enumeration | TFSharpRecdRepr _ | TFSharpUnionRepr _ -> if isStructTyconRef g tcref then @@ -149,9 +149,9 @@ module TcResolutionsExtensions = match occ with | ItemOccurence.UseInType | ItemOccurence.UseInAttribute - | ItemOccurence.Use _ - | ItemOccurence.Binding _ - | ItemOccurence.Pattern _ + | ItemOccurence.Use + | ItemOccurence.Binding + | ItemOccurence.Pattern | ItemOccurence.Open -> Some() | _ -> None diff --git a/src/Compiler/Service/ServiceDeclarationLists.fs b/src/Compiler/Service/ServiceDeclarationLists.fs index 399a3037ea..06cf656b07 100644 --- a/src/Compiler/Service/ServiceDeclarationLists.fs +++ b/src/Compiler/Service/ServiceDeclarationLists.fs @@ -862,7 +862,7 @@ module internal DescriptionListsImpl = | TFSharpInterface -> FSharpGlyph.Interface | TFSharpStruct -> FSharpGlyph.Struct | TFSharpDelegate _ -> FSharpGlyph.Delegate - | TFSharpEnum _ -> FSharpGlyph.Enum + | TFSharpEnum -> FSharpGlyph.Enum | TFSharpRecdRepr _ -> FSharpGlyph.Type | TFSharpUnionRepr _ -> FSharpGlyph.Union | TILObjectRepr (TILObjectReprData (_, _, td)) -> diff --git a/src/Compiler/Symbols/Symbols.fs b/src/Compiler/Symbols/Symbols.fs index 9adb5ffb1f..4b8f8c4684 100644 --- a/src/Compiler/Symbols/Symbols.fs +++ b/src/Compiler/Symbols/Symbols.fs @@ -2383,7 +2383,7 @@ type FSharpType(cenv, ty:TType) = isResolved() && protect <| fun () -> match stripTyparEqns ty with - | TType_app _ | TType_measure (Measure.Const _ | Measure.Prod _ | Measure.Inv _ | Measure.One _) -> true + | TType_app _ | TType_measure (Measure.Const _ | Measure.Prod _ | Measure.Inv _ | Measure.One) -> true | _ -> false member _.IsTupleType = diff --git a/src/Compiler/TypedTree/TypedTreeOps.fs b/src/Compiler/TypedTree/TypedTreeOps.fs index c166230e71..f57954f7bf 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.fs @@ -6049,7 +6049,7 @@ and remapTyconRepr ctxt tmenv repr = let ctxt = st.Context.RemapTyconRefs(unbox >> remapTyconRef tmenv.tyconRefRemap >> box) ProvidedType.ApplyContext (st, ctxt)) } #endif - | TNoRepr _ -> repr + | TNoRepr -> repr | TAsmRepr _ -> repr | TMeasureableRepr x -> TMeasureableRepr (remapType tmenv x) @@ -9684,10 +9684,10 @@ let rec EvalAttribArgExpr g x = | Const.Double _ | Const.Single _ | Const.Char _ - | Const.Zero _ + | Const.Zero | Const.String _ -> x - | Const.Decimal _ | Const.IntPtr _ | Const.UIntPtr _ | Const.Unit _ -> + | Const.Decimal _ | Const.IntPtr _ | Const.UIntPtr _ | Const.Unit -> errorR (Error ( FSComp.SR.tastNotAConstantExpression(), m)) x diff --git a/tests/FSharp.Test.Utilities/CompilerAssert.fs b/tests/FSharp.Test.Utilities/CompilerAssert.fs index 1679a74a33..c526d83da7 100644 --- a/tests/FSharp.Test.Utilities/CompilerAssert.fs +++ b/tests/FSharp.Test.Utilities/CompilerAssert.fs @@ -691,7 +691,7 @@ Updated automatically, please check diffs in your pull request, changes must be Assert.IsEmpty(parseResults.Diagnostics, sprintf "Parse errors: %A" parseResults.Diagnostics) match fileAnswer with - | FSharpCheckFileAnswer.Aborted _ -> Assert.Fail("Type Checker Aborted") + | FSharpCheckFileAnswer.Aborted -> Assert.Fail("Type Checker Aborted") | FSharpCheckFileAnswer.Succeeded(typeCheckResults) -> Assert.IsEmpty(typeCheckResults.Diagnostics, sprintf "Type Check errors: %A" typeCheckResults.Diagnostics) @@ -704,7 +704,7 @@ Updated automatically, please check diffs in your pull request, changes must be Assert.IsEmpty(parseResults.Diagnostics, sprintf "Parse errors: %A" parseResults.Diagnostics) match fileAnswer with - | FSharpCheckFileAnswer.Aborted _ -> Assert.Fail("Type Checker Aborted") + | FSharpCheckFileAnswer.Aborted -> Assert.Fail("Type Checker Aborted") | FSharpCheckFileAnswer.Succeeded(typeCheckResults) -> Assert.IsEmpty(typeCheckResults.Diagnostics, sprintf "Type Check errors: %A" typeCheckResults.Diagnostics) @@ -722,7 +722,7 @@ Updated automatically, please check diffs in your pull request, changes must be Assert.IsEmpty(parseResults.Diagnostics, sprintf "Parse errors: %A" parseResults.Diagnostics) match fileAnswer with - | FSharpCheckFileAnswer.Aborted _ -> Assert.Fail("Type Checker Aborted") + | FSharpCheckFileAnswer.Aborted -> Assert.Fail("Type Checker Aborted") | FSharpCheckFileAnswer.Succeeded(typeCheckResults) -> let errorsExpectedBaseLine = @@ -754,7 +754,7 @@ Updated automatically, please check diffs in your pull request, changes must be else match fileAnswer with - | FSharpCheckFileAnswer.Aborted _ -> Assert.Fail("Type Checker Aborted"); [| |] + | FSharpCheckFileAnswer.Aborted -> Assert.Fail("Type Checker Aborted"); [| |] | FSharpCheckFileAnswer.Succeeded(typeCheckResults) -> typeCheckResults.Diagnostics errors @@ -774,7 +774,7 @@ Updated automatically, please check diffs in your pull request, changes must be else match fileAnswer with - | FSharpCheckFileAnswer.Aborted _ -> Assert.Fail("Type Checker Aborted"); [| |] + | FSharpCheckFileAnswer.Aborted -> Assert.Fail("Type Checker Aborted"); [| |] | FSharpCheckFileAnswer.Succeeded(typeCheckResults) -> typeCheckResults.Diagnostics errors @@ -790,7 +790,7 @@ Updated automatically, please check diffs in your pull request, changes must be |> Async.RunImmediate match fileAnswer with - | FSharpCheckFileAnswer.Aborted _ -> Assert.Fail("Type Checker Aborted"); failwith "Type Checker Aborted" + | FSharpCheckFileAnswer.Aborted -> Assert.Fail("Type Checker Aborted"); failwith "Type Checker Aborted" | FSharpCheckFileAnswer.Succeeded(typeCheckResults) -> parseResults, typeCheckResults /// Parses and type checks the given source. Fails if the type checker is aborted or the parser returns any diagnostics. @@ -816,7 +816,7 @@ Updated automatically, please check diffs in your pull request, changes must be else match fileAnswer with - | FSharpCheckFileAnswer.Aborted _ -> Assert.Fail("Type Checker Aborted"); [| |] + | FSharpCheckFileAnswer.Aborted -> Assert.Fail("Type Checker Aborted"); [| |] | FSharpCheckFileAnswer.Succeeded(typeCheckResults) -> typeCheckResults.Diagnostics assertErrors libAdjust false errors expectedTypeErrors diff --git a/tests/service/data/TestTP/ProvidedTypes.fs b/tests/service/data/TestTP/ProvidedTypes.fs index e12c6f843d..c13961cbc2 100644 --- a/tests/service/data/TestTP/ProvidedTypes.fs +++ b/tests/service/data/TestTP/ProvidedTypes.fs @@ -629,8 +629,8 @@ type ProvidedTypeSymbol(kind: ProvidedTypeSymbolKind, typeArgs: Type list, typeB override __.GetArrayRank() = (match kind with ProvidedTypeSymbolKind.Array n -> n | ProvidedTypeSymbolKind.SDArray -> 1 | _ -> failwithf "non-array type '%O'" this) override __.IsValueTypeImpl() = (match kind with ProvidedTypeSymbolKind.Generic gtd -> gtd.IsValueType | _ -> false) override __.IsArrayImpl() = (match kind with ProvidedTypeSymbolKind.Array _ | ProvidedTypeSymbolKind.SDArray -> true | _ -> false) - override __.IsByRefImpl() = (match kind with ProvidedTypeSymbolKind.ByRef _ -> true | _ -> false) - override __.IsPointerImpl() = (match kind with ProvidedTypeSymbolKind.Pointer _ -> true | _ -> false) + override __.IsByRefImpl() = (match kind with ProvidedTypeSymbolKind.ByRef -> true | _ -> false) + override __.IsPointerImpl() = (match kind with ProvidedTypeSymbolKind.Pointer -> true | _ -> false) override __.IsPrimitiveImpl() = false override __.IsGenericType = (match kind with ProvidedTypeSymbolKind.Generic _ -> true | _ -> false) override this.GetGenericArguments() = (match kind with ProvidedTypeSymbolKind.Generic _ -> typeArgs | _ -> failwithf "non-generic type '%O'" this) @@ -7335,8 +7335,8 @@ namespace ProviderImplementation.ProvidedTypes override __.GetArrayRank() = (match kind with TypeSymbolKind.Array n -> n | TypeSymbolKind.SDArray -> 1 | _ -> failwithf "non-array type") override __.IsValueTypeImpl() = this.IsGenericType && this.GetGenericTypeDefinition().IsValueType override __.IsArrayImpl() = (match kind with TypeSymbolKind.Array _ | TypeSymbolKind.SDArray -> true | _ -> false) - override __.IsByRefImpl() = (match kind with TypeSymbolKind.ByRef _ -> true | _ -> false) - override __.IsPointerImpl() = (match kind with TypeSymbolKind.Pointer _ -> true | _ -> false) + override __.IsByRefImpl() = (match kind with TypeSymbolKind.ByRef -> true | _ -> false) + override __.IsPointerImpl() = (match kind with TypeSymbolKind.Pointer -> true | _ -> false) override __.IsPrimitiveImpl() = false override __.IsGenericType = (match kind with TypeSymbolKind.TargetGeneric _ | TypeSymbolKind.OtherGeneric _ -> true | _ -> false) override __.GetGenericArguments() = (match kind with TypeSymbolKind.TargetGeneric _ | TypeSymbolKind.OtherGeneric _ -> typeArgs | _ -> [| |]) From 0cab51a12827cbea1cf52290dab8e041137bb912 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sun, 9 Oct 2022 00:11:40 +0200 Subject: [PATCH 04/10] Format code --- src/Compiler/Driver/CompilerDiagnostics.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index ad18d9a65a..fb55d44480 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -1699,7 +1699,7 @@ type Exception with os.AppendString(MatchIncomplete4E().Format) | PatternMatchCompilation.RuleNeverMatched _ -> os.AppendString(RuleNeverMatchedE().Format) - + | PatternMatchCompilation.MatchNotAllowedForUnionCaseWithNoData _ -> os.AppendString(MatchNotAllowedForUnionCaseWithNoDataE().Format) From 09b3cbe2bf8bdcd12f23bf5f77e5c7b5ec40e22f Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sun, 9 Oct 2022 07:30:21 +0200 Subject: [PATCH 05/10] Remove unnecesary wildcard on tests --- .../ProvidedTypes.fs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/ProvidedTypes.fs b/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/ProvidedTypes.fs index ee27b6103b..4a7bc2764f 100644 --- a/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/ProvidedTypes.fs +++ b/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/ProvidedTypes.fs @@ -546,8 +546,8 @@ namespace ProviderImplementation.ProvidedTypes override _.GetArrayRank() = (match kind with ProvidedTypeSymbolKind.Array n -> n | ProvidedTypeSymbolKind.SDArray -> 1 | _ -> failwithf "non-array type '%O'" this) override _.IsValueTypeImpl() = (match kind with ProvidedTypeSymbolKind.Generic gtd -> gtd.IsValueType | _ -> false) override _.IsArrayImpl() = (match kind with ProvidedTypeSymbolKind.Array _ | ProvidedTypeSymbolKind.SDArray -> true | _ -> false) - override _.IsByRefImpl() = (match kind with ProvidedTypeSymbolKind.ByRef _ -> true | _ -> false) - override _.IsPointerImpl() = (match kind with ProvidedTypeSymbolKind.Pointer _ -> true | _ -> false) + override _.IsByRefImpl() = (match kind with ProvidedTypeSymbolKind.ByRef -> true | _ -> false) + override _.IsPointerImpl() = (match kind with ProvidedTypeSymbolKind.Pointer -> true | _ -> false) override _.IsPrimitiveImpl() = false override _.IsGenericType = (match kind with ProvidedTypeSymbolKind.Generic _ -> true | _ -> false) override this.GetGenericArguments() = (match kind with ProvidedTypeSymbolKind.Generic _ -> typeArgs | _ -> failwithf "non-generic type '%O'" this) @@ -6993,8 +6993,8 @@ namespace ProviderImplementation.ProvidedTypes override _.GetArrayRank() = (match kind with TypeSymbolKind.Array n -> n | TypeSymbolKind.SDArray -> 1 | _ -> failwithf "non-array type") override _.IsValueTypeImpl() = this.IsGenericType && this.GetGenericTypeDefinition().IsValueType override _.IsArrayImpl() = (match kind with TypeSymbolKind.Array _ | TypeSymbolKind.SDArray -> true | _ -> false) - override _.IsByRefImpl() = (match kind with TypeSymbolKind.ByRef _ -> true | _ -> false) - override _.IsPointerImpl() = (match kind with TypeSymbolKind.Pointer _ -> true | _ -> false) + override _.IsByRefImpl() = (match kind with TypeSymbolKind.ByRef -> true | _ -> false) + override _.IsPointerImpl() = (match kind with TypeSymbolKind.Pointer -> true | _ -> false) override _.IsPrimitiveImpl() = false override _.IsGenericType = (match kind with TypeSymbolKind.TargetGeneric _ | TypeSymbolKind.OtherGeneric _ -> true | _ -> false) override _.GetGenericArguments() = (match kind with TypeSymbolKind.TargetGeneric _ | TypeSymbolKind.OtherGeneric _ -> typeArgs | _ -> [| |]) From 9b04e0e733d7b9980a71ec4e17c3950b057b98af Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sun, 9 Oct 2022 09:18:10 +0200 Subject: [PATCH 06/10] Update the warning logic --- src/Compiler/Checking/CheckPatterns.fs | 3 +-- src/Compiler/Checking/PatternMatchCompilation.fs | 1 - src/Compiler/Checking/PatternMatchCompilation.fsi | 2 -- src/Compiler/Driver/CompilerDiagnostics.fs | 7 ------- src/Compiler/FSComp.txt | 1 + src/Compiler/FSStrings.resx | 3 --- 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 +++++ src/Compiler/xlf/FSStrings.cs.xlf | 5 ----- src/Compiler/xlf/FSStrings.de.xlf | 5 ----- src/Compiler/xlf/FSStrings.es.xlf | 5 ----- src/Compiler/xlf/FSStrings.fr.xlf | 5 ----- src/Compiler/xlf/FSStrings.it.xlf | 5 ----- src/Compiler/xlf/FSStrings.ja.xlf | 5 ----- src/Compiler/xlf/FSStrings.ko.xlf | 5 ----- src/Compiler/xlf/FSStrings.pl.xlf | 5 ----- src/Compiler/xlf/FSStrings.pt-BR.xlf | 5 ----- src/Compiler/xlf/FSStrings.ru.xlf | 5 ----- src/Compiler/xlf/FSStrings.tr.xlf | 5 ----- src/Compiler/xlf/FSStrings.zh-Hans.xlf | 5 ----- src/Compiler/xlf/FSStrings.zh-Hant.xlf | 5 ----- .../ErrorMessages/UnionCasePatternMatchingErrors.fs | 10 +++++----- 33 files changed, 72 insertions(+), 85 deletions(-) diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index aee2fbb47c..7f084af7a4 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -7,7 +7,6 @@ module internal FSharp.Compiler.CheckPatterns open System open System.Collections.Generic -open FSharp.Compiler.Text open Internal.Utilities.Library open Internal.Utilities.Library.Extras open FSharp.Compiler.AccessibilityLogic @@ -608,7 +607,7 @@ and TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (m | SynArgPats.Pats args -> match args with | [ SynPat.Wild _ ] when argNames.IsEmpty -> - warning(MatchNotAllowedForUnionCaseWithNoData(m)) + warning(Error(FSComp.SR.matchNotAllowedForUnionCaseWithNoData(), m)) args, [] | _ -> args, [] | SynArgPats.NamePatPairs (pairs, m, _) -> diff --git a/src/Compiler/Checking/PatternMatchCompilation.fs b/src/Compiler/Checking/PatternMatchCompilation.fs index 194f1e5d94..8d59e3301d 100644 --- a/src/Compiler/Checking/PatternMatchCompilation.fs +++ b/src/Compiler/Checking/PatternMatchCompilation.fs @@ -27,7 +27,6 @@ open FSharp.Compiler.TypeRelations exception MatchIncomplete of bool * (string * bool) option * range exception RuleNeverMatched of range exception EnumMatchIncomplete of bool * (string * bool) option * range -exception MatchNotAllowedForUnionCaseWithNoData of range type ActionOnFailure = | ThrowIncompleteMatchException diff --git a/src/Compiler/Checking/PatternMatchCompilation.fsi b/src/Compiler/Checking/PatternMatchCompilation.fsi index 5bbc2d3e7b..bc52ae8383 100644 --- a/src/Compiler/Checking/PatternMatchCompilation.fsi +++ b/src/Compiler/Checking/PatternMatchCompilation.fsi @@ -74,5 +74,3 @@ exception internal MatchIncomplete of bool * (string * bool) option * range exception internal RuleNeverMatched of range exception internal EnumMatchIncomplete of bool * (string * bool) option * range - -exception MatchNotAllowedForUnionCaseWithNoData of range diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index fb55d44480..6314212327 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -9,7 +9,6 @@ open System.IO open System.Reflection open System.Text -open FSharp.Compiler.CheckPatterns open Internal.Utilities.Library.Extras open Internal.Utilities.Library open Internal.Utilities.Text @@ -136,7 +135,6 @@ type Exception with | PatternMatchCompilation.MatchIncomplete (_, _, m) | PatternMatchCompilation.EnumMatchIncomplete (_, _, m) | PatternMatchCompilation.RuleNeverMatched m - | PatternMatchCompilation.MatchNotAllowedForUnionCaseWithNoData m | ValNotMutable (_, _, m) | ValNotLocal (_, _, m) | MissingFields (_, m) @@ -241,7 +239,6 @@ type Exception with | NameClash _ -> 23 // 24 cannot be reused | PatternMatchCompilation.MatchIncomplete _ -> 25 - | PatternMatchCompilation.MatchNotAllowedForUnionCaseWithNoData _ | PatternMatchCompilation.RuleNeverMatched _ -> 26 | ValNotMutable _ -> 27 @@ -555,7 +552,6 @@ module OldStyleMessages = let MatchIncomplete3E () = Message("MatchIncomplete3", "%s") let MatchIncomplete4E () = Message("MatchIncomplete4", "") let RuleNeverMatchedE () = Message("RuleNeverMatched", "") - let MatchNotAllowedForUnionCaseWithNoDataE () = Message("MatchNotAllowedForUnionCaseWithNoData", "") let EnumMatchIncomplete1E () = Message("EnumMatchIncomplete1", "") let ValNotMutableE () = Message("ValNotMutable", "%s") let ValNotLocalE () = Message("ValNotLocal", "") @@ -1700,9 +1696,6 @@ type Exception with | PatternMatchCompilation.RuleNeverMatched _ -> os.AppendString(RuleNeverMatchedE().Format) - | PatternMatchCompilation.MatchNotAllowedForUnionCaseWithNoData _ -> - os.AppendString(MatchNotAllowedForUnionCaseWithNoDataE().Format) - | ValNotMutable (_, vref, _) -> os.AppendString(ValNotMutableE().Format(vref.DisplayName)) | ValNotLocal _ -> os.AppendString(ValNotLocalE().Format) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index a298af5490..616d268269 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1654,3 +1654,4 @@ reprStateMachineInvalidForm,"The state machine has an unexpected form" 3545,tcMissingRequiredMembers,"The following required properties have to be initalized:%s" 3546,parsExpectingPatternInTuple,"Expecting pattern" 3547,parsExpectedPatternAfterToken,"Expected a pattern after this point" +3548,matchNotAllowedForUnionCaseWithNoData,"Pattern discard not allowed for union case that takes no data." diff --git a/src/Compiler/FSStrings.resx b/src/Compiler/FSStrings.resx index 6853139b4e..51f172fbbe 100644 --- a/src/Compiler/FSStrings.resx +++ b/src/Compiler/FSStrings.resx @@ -1110,7 +1110,4 @@ Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute - - Pattern discard not allowed for union case that takes no data. - \ No newline at end of file diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 1d56df844c..45ec09c2f5 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -402,6 +402,11 @@ Neplatný interpolovaný řetězec. V interpolovaných výrazech se nedají použít řetězcové literály s trojitými uvozovkami. Zvažte možnost použít pro interpolovaný výraz explicitní vazbu let. + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. Tento konstruktor je zastaralý. {0}. Tuto funkci můžete povolit pomocí parametrů --langversion:5.0 a --mlcompatibility. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 0756782570..626c3a089e 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -402,6 +402,11 @@ Ungültige interpolierte Zeichenfolge. Zeichenfolgenliterale mit dreifachen Anführungszeichen dürfen in interpolierten Ausdrücken nicht verwendet werden. Erwägen Sie die Verwendung einer expliziten let-Bindung für den Interpolationsausdruck. + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. Dieses Konstrukt ist veraltet. {0}. Sie können dieses Feature mithilfe von „--langversion:5.0“ und „--mlcompatibility“ aktivieren. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index b627eaf231..ab086d99bc 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -402,6 +402,11 @@ Cadena interpolada no válida. No se pueden usar literales de cadena de comillas triples en las expresiones interpoladas. Puede usar un enlace "let" explícito para la expresión de interpolación. + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. Esta construcción está en desuso. {0}. Puede habilitar esta característica usando '--langversion:5.0' y '--mlcompatibility'. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 8ff78e1d34..2477c6b748 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -402,6 +402,11 @@ Chaîne interpolée non valide. Les littéraux de chaîne à guillemets triples ne peuvent pas être utilisés dans des expressions interpolées. Utilisez une liaison 'let' explicite pour l'expression d'interpolation. + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. Cette construction est déconseillée. {0}. Vous pouvez activer cette fonctionnalité à l’aide de'--langversion : 5.0 'et'--mlcompatibility'. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 4f1344f084..7552455cbc 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -402,6 +402,11 @@ La stringa interpolata non è valida. Non è possibile usare valori letterali stringa tra virgolette triple in espressioni interpolate. Provare a usare un binding 'let' esplicito per l'espressione di interpolazione. + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. Questo costrutto è deprecato. {0}. È possibile abilitare questa funzionalità usando '--langversion:5.0' and '--mlcompatibility'. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 3be4cc8799..f5a9c54fc2 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -402,6 +402,11 @@ 補間された文字列が無効です。三重引用符文字列リテラルは、補間された式では使用できません。補間式に対して明示的な 'let' バインドを使用することをご検討ください。 + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. このコンストラクトは使用されなくなりました。{0}。'--langversion:5.0' と '--mlcompatibility' を使用することで、この機能を有効にすることができます。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 728c94688d..80739f86c3 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -402,6 +402,11 @@ 잘못된 보간 문자열. 삼중 따옴표 문자열 리터럴은 보간 식에 사용할 수 없습니다. 보간 식에 명시적 'let' 바인딩을 사용해 보세요. + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. 이 구성은 더 이상 사용되지 않습니다. {0}. '--langversion:5.0' 및 '--mlcompatibility'를 사용하여 이 기능을 활성화할 수 있습니다. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 284aef3e01..42f2b15b26 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -402,6 +402,11 @@ Nieprawidłowy ciąg interpolowany. Literały ciągów z potrójnymi cudzysłowami nie mogą być używane w wyrażeniach interpolowanych. Rozważ użycie jawnego powiązania „let” dla wyrażenia interpolacji. + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. Ta konstrukcja jest przestarzała. {0}. Tę funkcję można włączyć przy użyciu poleceń"--langversion:5.0" i "--mlcompatibility". diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index a5b2b95436..8331c9b9b1 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -402,6 +402,11 @@ Cadeia de caracteres interpolada inválida. Literais de cadeia de caracteres de aspas triplas não podem ser usados em expressões interpoladas. Considere usar uma associação 'let' explícita para a expressão de interpolação. + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. Esta construção foi preterida. {0} Você pode habilitar este recurso usando '--langversion:5.0' e '--mlcompatibility'. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 545decc436..bc66d9c1c5 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -402,6 +402,11 @@ Недопустимая интерполированная строка. Строковые литералы с тройными кавычками запрещено использовать в интерполированных выражениях. Рекомендуется использовать явную привязку "let" для выражения интерполяции. + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. Эта конструкция не рекомендуется к использованию. {0}. Вы можете включить эту функцию с помощью команд "--langversion:5.0" и "--mlcompatibility". diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 1c0cfc9042..df13388b4a 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -402,6 +402,11 @@ Geçersiz düz metin arasına kod eklenmiş dize. Üç tırnaklı dize sabitleri, düz metin arasına kod eklenmiş ifadelerde kullanılamaz. Düz metin arasına kod ekleme ifadesi için açık bir 'let' bağlaması kullanmayı düşünün. + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. Bu yapı kullanım dışı. {0}. Bu özelliği '--langversion:5.0' ve '--mlcompatibility' kullanarak etkinleştirebilirsiniz. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index bf7eeca1f7..1242f394e1 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -402,6 +402,11 @@ 内插字符串无效。在内插表达式中不能使用三重引号字符串文字。请考虑对内插表达式使用显式的 "let" 绑定。 + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. 此构造已弃用。{0}。可以通过使用 “--langversion:5.0” 和 “--mlcompatibility” 启用此功能。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index f2d4f429c8..5863b99061 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -402,6 +402,11 @@ 插補字串無效。三引號字串常值不可用於插補運算式。請考慮為內插補點運算式使用明確的 'let' 繫結。 + + Pattern discard not allowed for union case that takes no data. + Pattern discard not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. 此建構已被取代。{0}。您可以使用 '--langversion:5.0' and '--mlcompatibility' 來啟用此功能。 diff --git a/src/Compiler/xlf/FSStrings.cs.xlf b/src/Compiler/xlf/FSStrings.cs.xlf index 0b9d82804d..f80da09f75 100644 --- a/src/Compiler/xlf/FSStrings.cs.xlf +++ b/src/Compiler/xlf/FSStrings.cs.xlf @@ -7,11 +7,6 @@ Nejméně jedna informační zpráva v načteném souboru\n - - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. - - Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.de.xlf b/src/Compiler/xlf/FSStrings.de.xlf index e5ce71091e..8978b17675 100644 --- a/src/Compiler/xlf/FSStrings.de.xlf +++ b/src/Compiler/xlf/FSStrings.de.xlf @@ -7,11 +7,6 @@ Mindestens eine Informationsmeldung in der geladenen Datei.\n - - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. - - Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.es.xlf b/src/Compiler/xlf/FSStrings.es.xlf index 79b0d1ef8c..bc0ce4ad5a 100644 --- a/src/Compiler/xlf/FSStrings.es.xlf +++ b/src/Compiler/xlf/FSStrings.es.xlf @@ -7,11 +7,6 @@ Uno o más mensajes informativos en el archivo cargado.\n - - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. - - Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.fr.xlf b/src/Compiler/xlf/FSStrings.fr.xlf index 513579ece8..f88d8e7182 100644 --- a/src/Compiler/xlf/FSStrings.fr.xlf +++ b/src/Compiler/xlf/FSStrings.fr.xlf @@ -7,11 +7,6 @@ Un ou plusieurs messages d’information dans le fichier chargé.\n - - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. - - Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.it.xlf b/src/Compiler/xlf/FSStrings.it.xlf index 486594f38c..90d7b1611f 100644 --- a/src/Compiler/xlf/FSStrings.it.xlf +++ b/src/Compiler/xlf/FSStrings.it.xlf @@ -7,11 +7,6 @@ Uno o più messaggi informativi nel file caricato.\n - - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. - - Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.ja.xlf b/src/Compiler/xlf/FSStrings.ja.xlf index e94454a448..b0a149427b 100644 --- a/src/Compiler/xlf/FSStrings.ja.xlf +++ b/src/Compiler/xlf/FSStrings.ja.xlf @@ -7,11 +7,6 @@ 読み込まれたファイル内の 1 つ以上の情報メッセージ。\n - - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. - - Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.ko.xlf b/src/Compiler/xlf/FSStrings.ko.xlf index 0f91fc636e..95015040f0 100644 --- a/src/Compiler/xlf/FSStrings.ko.xlf +++ b/src/Compiler/xlf/FSStrings.ko.xlf @@ -7,11 +7,6 @@ 로드된 파일에 하나 이상의 정보 메시지가 있습니다.\n - - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. - - Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.pl.xlf b/src/Compiler/xlf/FSStrings.pl.xlf index 0d7990b171..48a2f8aded 100644 --- a/src/Compiler/xlf/FSStrings.pl.xlf +++ b/src/Compiler/xlf/FSStrings.pl.xlf @@ -7,11 +7,6 @@ Jeden lub więcej komunikatów informacyjnych w załadowanym pliku.\n - - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. - - Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.pt-BR.xlf b/src/Compiler/xlf/FSStrings.pt-BR.xlf index d412cb996b..1929c486cd 100644 --- a/src/Compiler/xlf/FSStrings.pt-BR.xlf +++ b/src/Compiler/xlf/FSStrings.pt-BR.xlf @@ -7,11 +7,6 @@ Uma ou mais mensagens informativas no arquivo carregado.\n - - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. - - Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.ru.xlf b/src/Compiler/xlf/FSStrings.ru.xlf index f57c99e1d5..1e91c13cd4 100644 --- a/src/Compiler/xlf/FSStrings.ru.xlf +++ b/src/Compiler/xlf/FSStrings.ru.xlf @@ -7,11 +7,6 @@ Одно или несколько информационных сообщений в загруженном файле.\n - - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. - - Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.tr.xlf b/src/Compiler/xlf/FSStrings.tr.xlf index ba262181d2..31b4cad81a 100644 --- a/src/Compiler/xlf/FSStrings.tr.xlf +++ b/src/Compiler/xlf/FSStrings.tr.xlf @@ -7,11 +7,6 @@ Yüklenen dosyada bir veya daha fazla bilgi mesajı.\n - - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. - - Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.zh-Hans.xlf b/src/Compiler/xlf/FSStrings.zh-Hans.xlf index c3ea42dc7e..be3604df4b 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hans.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hans.xlf @@ -7,11 +7,6 @@ 加载文件 .\n 中有一条或多条信息性消息 - - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. - - Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/src/Compiler/xlf/FSStrings.zh-Hant.xlf b/src/Compiler/xlf/FSStrings.zh-Hant.xlf index dc79e8f7e5..67e6c25370 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hant.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hant.xlf @@ -7,11 +7,6 @@ 已載入檔案中的一或多個資訊訊息。\n - - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. - - Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs index bfdd826c3e..19b9c2866b 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs @@ -84,7 +84,7 @@ let myVal = | X _ -> ()""" |> typecheck |> shouldFail - |> withSingleDiagnostic (Warning 26, Line 9, Col 7, Line 9, Col 10, "Pattern discard not allowed for union case that takes no data.") + |> withSingleDiagnostic (Warning 3548, Line 9, Col 7, Line 9, Col 10, "Pattern discard not allowed for union case that takes no data.") [] let ``Pattern discard not allowed for union case that takes no data`` () = @@ -104,7 +104,7 @@ let myVal = | C _ -> 17""" |> typecheck |> shouldFail - |> withSingleDiagnostic (Warning 26, Line 12, Col 7, Line 12, Col 10, "Pattern discard not allowed for union case that takes no data.") + |> withSingleDiagnostic (Warning 3548, Line 12, Col 7, Line 12, Col 10, "Pattern discard not allowed for union case that takes no data.") [] let ``Grouped Pattern discard not allowed for union case that takes no data`` () = @@ -124,7 +124,7 @@ let myVal = | C _ -> 17""" |> typecheck |> shouldFail - |> withSingleDiagnostic (Warning 26, Line 12, Col 7, Line 12, Col 10, "Pattern discard not allowed for union case that takes no data.") + |> withSingleDiagnostic (Warning 3548, Line 12, Col 7, Line 12, Col 10, "Pattern discard not allowed for union case that takes no data.") [] let ``Multiple pattern discards not allowed for union case that takes no data`` () = FSharp """ @@ -148,6 +148,6 @@ let myVal = |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 26, Line 16, Col 7, Line 16, Col 10, "Pattern discard not allowed for union case that takes no data.") - (Warning 26, Line 17, Col 20, Line 17, Col 23, "Pattern discard not allowed for union case that takes no data.") + (Warning 3548, Line 16, Col 7, Line 16, Col 10, "Pattern discard not allowed for union case that takes no data.") + (Warning 3548, Line 17, Col 20, Line 17, Col 23, "Pattern discard not allowed for union case that takes no data.") ] \ No newline at end of file From 0d6fa29f59128a432677c0067a894be13ab0b3b5 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sun, 9 Oct 2022 11:03:35 +0200 Subject: [PATCH 07/10] Add warning behing preview flag --- src/Compiler/Checking/CheckPatterns.fs | 11 +++-- src/Compiler/FSComp.txt | 1 + src/Compiler/Facilities/LanguageFeatures.fs | 3 ++ src/Compiler/Facilities/LanguageFeatures.fsi | 1 + 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 +++ .../UnionCasePatternMatchingErrors.fs | 43 ++++++++++++++++++- 18 files changed, 119 insertions(+), 5 deletions(-) diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index 7f084af7a4..88fcf401af 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -605,11 +605,14 @@ and TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (m let args, extraPatternsFromNames = match args with | SynArgPats.Pats args -> - match args with - | [ SynPat.Wild _ ] when argNames.IsEmpty -> - warning(Error(FSComp.SR.matchNotAllowedForUnionCaseWithNoData(), m)) + if g.langVersion.SupportsFeature(LanguageFeature.MatchNotAllowedForUnionCaseWithNoData) then + match args with + | [ SynPat.Wild _ ] when argNames.IsEmpty -> + warning(Error(FSComp.SR.matchNotAllowedForUnionCaseWithNoData(), m)) + args, [] + | _ -> args, [] + else args, [] - | _ -> args, [] | SynArgPats.NamePatPairs (pairs, m, _) -> // rewrite patterns from the form (name-N = pat-N; ...) to (..._, pat-N, _...) // so type T = Case of name: int * value: int diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 616d268269..78f76ddcad 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1554,6 +1554,7 @@ featureSelfTypeConstraints,"self type constraints" featureRequiredProperties,"support for required properties" featureInitProperties,"support for consuming init properties" featureLowercaseDUWhenRequireQualifiedAccess,"Allow lowercase DU when RequireQualifiedAccess attribute" +featureMatchNotAllowedForUnionCaseWithNoData,"Pattern match discard not allowed for union case that takes no data." 3353,fsiInvalidDirective,"Invalid directive '#%s %s'" 3354,tcNotAFunctionButIndexerNamedIndexingNotYetEnabled,"This value supports indexing, e.g. '%s.[index]'. The syntax '%s[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." 3354,tcNotAFunctionButIndexerIndexingNotYetEnabled,"This expression supports indexing, e.g. 'expr.[index]'. The syntax 'expr[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index 07bcca5787..8644fbe997 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -54,6 +54,7 @@ type LanguageFeature = | LowercaseDUWhenRequireQualifiedAccess | InterfacesWithAbstractStaticMembers | SelfTypeConstraints + | MatchNotAllowedForUnionCaseWithNoData /// LanguageVersion management type LanguageVersion(versionText) = @@ -124,6 +125,7 @@ type LanguageVersion(versionText) = // F# preview LanguageFeature.FromEndSlicing, previewVersion + LanguageFeature.MatchNotAllowedForUnionCaseWithNoData, previewVersion ] static let defaultLanguageVersion = LanguageVersion("default") @@ -230,6 +232,7 @@ type LanguageVersion(versionText) = | LanguageFeature.LowercaseDUWhenRequireQualifiedAccess -> FSComp.SR.featureLowercaseDUWhenRequireQualifiedAccess () | LanguageFeature.InterfacesWithAbstractStaticMembers -> FSComp.SR.featureInterfacesWithAbstractStaticMembers () | LanguageFeature.SelfTypeConstraints -> FSComp.SR.featureSelfTypeConstraints () + | LanguageFeature.MatchNotAllowedForUnionCaseWithNoData -> FSComp.SR.featureMatchNotAllowedForUnionCaseWithNoData () /// Get a version string associated with the given feature. static member GetFeatureVersionString feature = diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index cb7991392c..694a6ae73f 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -44,6 +44,7 @@ type LanguageFeature = | LowercaseDUWhenRequireQualifiedAccess | InterfacesWithAbstractStaticMembers | SelfTypeConstraints + | MatchNotAllowedForUnionCaseWithNoData /// LanguageVersion management type LanguageVersion = diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 45ec09c2f5..2c2516d272 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -212,6 +212,11 @@ Revize kompatibility ML + + Pattern match discard not allowed for union case that takes no data. + Pattern match discard not allowed for union case that takes no data. + + nameof nameof diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 626c3a089e..007253ad4f 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -212,6 +212,11 @@ ML-Kompatibilitätsrevisionen + + Pattern match discard not allowed for union case that takes no data. + Pattern match discard not allowed for union case that takes no data. + + nameof nameof diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index ab086d99bc..8623da2613 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -212,6 +212,11 @@ Revisiones de compatibilidad de ML + + Pattern match discard not allowed for union case that takes no data. + Pattern match discard not allowed for union case that takes no data. + + nameof nameof diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 2477c6b748..aedc2f4761 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -212,6 +212,11 @@ Réviseurs de compatibilité ML + + Pattern match discard not allowed for union case that takes no data. + Pattern match discard not allowed for union case that takes no data. + + nameof nameof diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 7552455cbc..4d7baf4a35 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -212,6 +212,11 @@ Revisioni della compatibilità di Ml + + Pattern match discard not allowed for union case that takes no data. + Pattern match discard not allowed for union case that takes no data. + + nameof nameof diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index f5a9c54fc2..45d43b2e31 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -212,6 +212,11 @@ ML 互換性のリビジョン + + Pattern match discard not allowed for union case that takes no data. + Pattern match discard not allowed for union case that takes no data. + + nameof nameof diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 80739f86c3..9318356fb9 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -212,6 +212,11 @@ ML 호환성 개정 + + Pattern match discard not allowed for union case that takes no data. + Pattern match discard not allowed for union case that takes no data. + + nameof nameof diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 42f2b15b26..7b3bb9a1eb 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -212,6 +212,11 @@ Poprawki dotyczące zgodności Machine Learning + + Pattern match discard not allowed for union case that takes no data. + Pattern match discard not allowed for union case that takes no data. + + nameof nameof diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 8331c9b9b1..7c94e3664f 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -212,6 +212,11 @@ Revisões de compatibilidade de ML + + Pattern match discard not allowed for union case that takes no data. + Pattern match discard not allowed for union case that takes no data. + + nameof nameof diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index bc66d9c1c5..ac0b7019b7 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -212,6 +212,11 @@ Редакции совместимости ML + + Pattern match discard not allowed for union case that takes no data. + Pattern match discard not allowed for union case that takes no data. + + nameof nameof diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index df13388b4a..ba89d9f1d2 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -212,6 +212,11 @@ ML uyumluluk düzeltmeleri + + Pattern match discard not allowed for union case that takes no data. + Pattern match discard not allowed for union case that takes no data. + + nameof nameof diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 1242f394e1..9d55f7f0e4 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -212,6 +212,11 @@ ML 兼容性修订 + + Pattern match discard not allowed for union case that takes no data. + Pattern match discard not allowed for union case that takes no data. + + nameof nameof diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 5863b99061..17846a8550 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -212,6 +212,11 @@ ML 相容性修訂 + + Pattern match discard not allowed for union case that takes no data. + Pattern match discard not allowed for union case that takes no data. + + nameof nameof diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs index 19b9c2866b..9802b3d39c 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs @@ -82,10 +82,27 @@ let x: X = X let myVal = match x with | X _ -> ()""" + |> withLangVersionPreview |> typecheck |> shouldFail |> withSingleDiagnostic (Warning 3548, Line 9, Col 7, Line 9, Col 10, "Pattern discard not allowed for union case that takes no data.") + +[] +let ``Union Pattern discard not allowed for union case that takes no data with Lang version 7`` () = + FSharp """ +module Tests +type X = X + +let x: X = X + +let myVal = + match x with + | X _ -> ()""" + |> withLangVersion70 + |> typecheck + |> shouldSucceed + [] let ``Pattern discard not allowed for union case that takes no data`` () = FSharp """ @@ -102,10 +119,31 @@ let myVal = | A _ -> 15 | B (x, _, _) -> 16 | C _ -> 17""" + |> withLangVersionPreview |> typecheck |> shouldFail |> withSingleDiagnostic (Warning 3548, Line 12, Col 7, Line 12, Col 10, "Pattern discard not allowed for union case that takes no data.") - + +[] +let ``Pattern discard not allowed for union case that takes no data with Lang version 7`` () = + FSharp """ +module Tests +type U = + | A + | B of int * int * int + | C of int * int * int + +let a : U = A + +let myVal = + match a with + | A _ -> 15 + | B (x, _, _) -> 16 + | C _ -> 17""" + |> withLangVersion70 + |> typecheck + |> shouldSucceed + [] let ``Grouped Pattern discard not allowed for union case that takes no data`` () = FSharp """ @@ -122,9 +160,11 @@ let myVal = | A _ | B _ | C _ -> 17""" + |> withLangVersionPreview |> typecheck |> shouldFail |> withSingleDiagnostic (Warning 3548, Line 12, Col 7, Line 12, Col 10, "Pattern discard not allowed for union case that takes no data.") + [] let ``Multiple pattern discards not allowed for union case that takes no data`` () = FSharp """ @@ -145,6 +185,7 @@ let myVal = | A _, D -> 15 | B (x, _, _), D _ -> 16 | C _, _ -> 17""" + |> withLangVersionPreview |> typecheck |> shouldFail |> withDiagnostics [ From 61d4df0f6d5b00d9792e1ce45da2dc7fa41a621d Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Mon, 10 Oct 2022 13:45:48 +0200 Subject: [PATCH 08/10] More testing --- .../UnionCasePatternMatchingErrors.fs | 92 +++++++++++++++++-- 1 file changed, 86 insertions(+), 6 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs index 9802b3d39c..3c11b92b31 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs @@ -72,7 +72,7 @@ let myVal = \tint") [] -let ``Union Pattern discard not allowed for union case that takes no data`` () = +let ``Union Pattern discard not allowed for union case that takes no data with Lang preview`` () = FSharp """ module Tests type X = X @@ -89,7 +89,7 @@ let myVal = [] -let ``Union Pattern discard not allowed for union case that takes no data with Lang version 7`` () = +let ``Union Pattern discard allowed for union case that takes no data with Lang version 7`` () = FSharp """ module Tests type X = X @@ -104,7 +104,38 @@ let myVal = |> shouldSucceed [] -let ``Pattern discard not allowed for union case that takes no data`` () = +let ``Union function Pattern discard allowed for union case that takes no data with Lang version 7`` () = + FSharp """ +module Tests +type X = X + +let x: X = X + +let myVal = + function + | X _ -> ()""" + |> withLangVersion70 + |> typecheck + |> shouldSucceed + +[] +let ``Union function Pattern discard not allowed for union case that takes no data with Lang version preview`` () = + FSharp """ +module Tests +type X = X + +let x: X = X + +let myVal = + function + | X _ -> ()""" + |> withLangVersionPreview + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 3548, Line 9, Col 7, Line 9, Col 10, "Pattern discard not allowed for union case that takes no data.") + +[] +let ``Pattern discard not allowed for union case that takes no data with Lang preview`` () = FSharp """ module Tests type U = @@ -123,9 +154,30 @@ let myVal = |> typecheck |> shouldFail |> withSingleDiagnostic (Warning 3548, Line 12, Col 7, Line 12, Col 10, "Pattern discard not allowed for union case that takes no data.") + +[] +let ``Pattern function discard not allowed for union case that takes no data with Lang preview`` () = + FSharp """ +module Tests +type U = + | A + | B of int * int * int + | C of int * int * int + +let a : U = A + +let myVal = + function + | A _ -> 15 + | B (x, _, _) -> 16 + | C _ -> 17""" + |> withLangVersionPreview + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 3548, Line 12, Col 7, Line 12, Col 10, "Pattern discard not allowed for union case that takes no data.") [] -let ``Pattern discard not allowed for union case that takes no data with Lang version 7`` () = +let ``Pattern discard allowed for union case that takes no data with Lang version 7`` () = FSharp """ module Tests type U = @@ -145,7 +197,7 @@ let myVal = |> shouldSucceed [] -let ``Grouped Pattern discard not allowed for union case that takes no data`` () = +let ``Grouped Pattern discard not allowed for union case that takes no data with Lang preview`` () = FSharp """ module Tests type U = @@ -166,7 +218,7 @@ let myVal = |> withSingleDiagnostic (Warning 3548, Line 12, Col 7, Line 12, Col 10, "Pattern discard not allowed for union case that takes no data.") [] -let ``Multiple pattern discards not allowed for union case that takes no data`` () = +let ``Multiple pattern discards not allowed for union case that takes no data with Lang preview`` () = FSharp """ module Tests type U = @@ -188,6 +240,34 @@ let myVal = |> withLangVersionPreview |> typecheck |> shouldFail + |> withDiagnostics [ + (Warning 3548, Line 16, Col 7, Line 16, Col 10, "Pattern discard not allowed for union case that takes no data.") + (Warning 3548, Line 17, Col 20, Line 17, Col 23, "Pattern discard not allowed for union case that takes no data.") + ] + +[] +let ``Multiple function pattern discards not allowed for union case that takes no data with Lang preview`` () = + FSharp """ +module Tests +type U = + | A + | B of int * int * int + | C of int * int * int + +type V = + | D + +let a : U = A +let d : V = D + +let myVal = + function + | A _, D -> 15 + | B (x, _, _), D _ -> 16 + | C _, _ -> 17""" + |> withLangVersionPreview + |> typecheck + |> shouldFail |> withDiagnostics [ (Warning 3548, Line 16, Col 7, Line 16, Col 10, "Pattern discard not allowed for union case that takes no data.") (Warning 3548, Line 17, Col 20, Line 17, Col 23, "Pattern discard not allowed for union case that takes no data.") From 0580e6bf72bbf2d2fc2e01cbd994445a0070015f Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Mon, 10 Oct 2022 18:47:34 +0200 Subject: [PATCH 09/10] Add single-case unions when using them as a deconstruct syntax in functions --- src/Compiler/Checking/CheckPatterns.fs | 10 +-- .../UnionCasePatternMatchingErrors.fs | 61 ++++++++++++++++--- 2 files changed, 57 insertions(+), 14 deletions(-) diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index 88fcf401af..87b0678b69 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -607,7 +607,7 @@ and TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (m | SynArgPats.Pats args -> if g.langVersion.SupportsFeature(LanguageFeature.MatchNotAllowedForUnionCaseWithNoData) then match args with - | [ SynPat.Wild _ ] when argNames.IsEmpty -> + | [ SynPat.Wild _ ] | [ SynPat.Named _ ] when argNames.IsEmpty -> warning(Error(FSComp.SR.matchNotAllowedForUnionCaseWithNoData(), m)) args, [] | _ -> args, [] @@ -669,10 +669,12 @@ and TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (m // note: we allow both 'C _' and 'C (_)' regardless of number of argument of the pattern | [SynPatErrorSkip(SynPat.Wild _ as e) | SynPatErrorSkip(SynPat.Paren(SynPatErrorSkip(SynPat.Wild _ as e), _))] -> List.replicate numArgTys e, [] - | args when numArgTys = 0 -> - errorR (Error (FSComp.SR.tcUnionCaseDoesNotTakeArguments (), m)) - [], args + if g.langVersion.SupportsFeature(LanguageFeature.MatchNotAllowedForUnionCaseWithNoData) then + [], args + else + errorR (Error (FSComp.SR.tcUnionCaseDoesNotTakeArguments (), m)) + [], args | arg :: rest when numArgTys = 1 -> if numArgTys = 1 && not (List.isEmpty rest) then diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs index 3c11b92b31..63973ea991 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs @@ -85,7 +85,7 @@ let myVal = |> withLangVersionPreview |> typecheck |> shouldFail - |> withSingleDiagnostic (Warning 3548, Line 9, Col 7, Line 9, Col 10, "Pattern discard not allowed for union case that takes no data.") + |> withSingleDiagnostic (Warning 3548, Line 9, Col 7, Line 9, Col 10, "Pattern discard is not allowed for union case that takes no data.") [] @@ -132,7 +132,7 @@ let myVal = |> withLangVersionPreview |> typecheck |> shouldFail - |> withSingleDiagnostic (Warning 3548, Line 9, Col 7, Line 9, Col 10, "Pattern discard not allowed for union case that takes no data.") + |> withSingleDiagnostic (Warning 3548, Line 9, Col 7, Line 9, Col 10, "Pattern discard is not allowed for union case that takes no data.") [] let ``Pattern discard not allowed for union case that takes no data with Lang preview`` () = @@ -153,7 +153,7 @@ let myVal = |> withLangVersionPreview |> typecheck |> shouldFail - |> withSingleDiagnostic (Warning 3548, Line 12, Col 7, Line 12, Col 10, "Pattern discard not allowed for union case that takes no data.") + |> withSingleDiagnostic (Warning 3548, Line 12, Col 7, Line 12, Col 10, "Pattern discard is not allowed for union case that takes no data.") [] let ``Pattern function discard not allowed for union case that takes no data with Lang preview`` () = @@ -174,7 +174,7 @@ let myVal = |> withLangVersionPreview |> typecheck |> shouldFail - |> withSingleDiagnostic (Warning 3548, Line 12, Col 7, Line 12, Col 10, "Pattern discard not allowed for union case that takes no data.") + |> withSingleDiagnostic (Warning 3548, Line 12, Col 7, Line 12, Col 10, "Pattern discard is not allowed for union case that takes no data.") [] let ``Pattern discard allowed for union case that takes no data with Lang version 7`` () = @@ -215,7 +215,7 @@ let myVal = |> withLangVersionPreview |> typecheck |> shouldFail - |> withSingleDiagnostic (Warning 3548, Line 12, Col 7, Line 12, Col 10, "Pattern discard not allowed for union case that takes no data.") + |> withSingleDiagnostic (Warning 3548, Line 12, Col 7, Line 12, Col 10, "Pattern discard is not allowed for union case that takes no data.") [] let ``Multiple pattern discards not allowed for union case that takes no data with Lang preview`` () = @@ -241,12 +241,12 @@ let myVal = |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 3548, Line 16, Col 7, Line 16, Col 10, "Pattern discard not allowed for union case that takes no data.") - (Warning 3548, Line 17, Col 20, Line 17, Col 23, "Pattern discard not allowed for union case that takes no data.") + (Warning 3548, Line 16, Col 7, Line 16, Col 10, "Pattern discard is not allowed for union case that takes no data.") + (Warning 3548, Line 17, Col 20, Line 17, Col 23, "Pattern discard is not allowed for union case that takes no data.") ] [] -let ``Multiple function pattern discards not allowed for union case that takes no data with Lang preview`` () = +let ``Multiple function pattern discards is not allowed for union case that takes no data with Lang preview`` () = FSharp """ module Tests type U = @@ -269,6 +269,47 @@ let myVal = |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 3548, Line 16, Col 7, Line 16, Col 10, "Pattern discard not allowed for union case that takes no data.") - (Warning 3548, Line 17, Col 20, Line 17, Col 23, "Pattern discard not allowed for union case that takes no data.") + (Warning 3548, Line 16, Col 7, Line 16, Col 10, "Pattern discard is not allowed for union case that takes no data.") + (Warning 3548, Line 17, Col 20, Line 17, Col 23, "Pattern discard is not allowed for union case that takes no data.") + ] + +[] +let ``Pattern discard allowed for single-case unions when using them as a deconstruct syntax in functions with Lang 7`` () = + FSharp """ +module Tests +type MyWrapper = A + +let myDiscardedArgFunc(A _) = 5+5""" + |> withLangVersion70 + |> typecheck + |> shouldSucceed + +[] +let ``Pattern named not allowed for single-case unions when using them as a deconstruct syntax in functions with Lang 7`` () = + FSharp """ +module Tests +type MyWrapper = A + +let myFunc(A a) = 5+5""" + |> withLangVersion70 + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 725, Line 5, Col 12, Line 5, Col 15, "This union case does not take arguments") + ] + +[] +let ``Pattern discard or named are not allowed for single-case union case that takes no data with Lang preview`` () = + FSharp """ +module Tests +type MyWrapper = A + +let myFunc(A a) = 5+5 +let myDiscardedArgFunc(A _) = 5+5""" + |> withLangVersionPreview + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 3548, Line 5, Col 12, Line 5, Col 15, "Pattern discard is not allowed for union case that takes no data.") + (Warning 3548, Line 6, Col 24, Line 6, Col 27, "Pattern discard is not allowed for union case that takes no data.") ] \ No newline at end of file From 286098ae51be842b5f0f7bb2c818c5b430556488 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Mon, 10 Oct 2022 18:48:06 +0200 Subject: [PATCH 10/10] Update FSComp.txt --- 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 ++++---- 14 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 78f76ddcad..80c356d31d 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1554,7 +1554,7 @@ featureSelfTypeConstraints,"self type constraints" featureRequiredProperties,"support for required properties" featureInitProperties,"support for consuming init properties" featureLowercaseDUWhenRequireQualifiedAccess,"Allow lowercase DU when RequireQualifiedAccess attribute" -featureMatchNotAllowedForUnionCaseWithNoData,"Pattern match discard not allowed for union case that takes no data." +featureMatchNotAllowedForUnionCaseWithNoData,"Pattern match discard is not allowed for union case that takes no data." 3353,fsiInvalidDirective,"Invalid directive '#%s %s'" 3354,tcNotAFunctionButIndexerNamedIndexingNotYetEnabled,"This value supports indexing, e.g. '%s.[index]'. The syntax '%s[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." 3354,tcNotAFunctionButIndexerIndexingNotYetEnabled,"This expression supports indexing, e.g. 'expr.[index]'. The syntax 'expr[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." @@ -1655,4 +1655,4 @@ reprStateMachineInvalidForm,"The state machine has an unexpected form" 3545,tcMissingRequiredMembers,"The following required properties have to be initalized:%s" 3546,parsExpectingPatternInTuple,"Expecting pattern" 3547,parsExpectedPatternAfterToken,"Expected a pattern after this point" -3548,matchNotAllowedForUnionCaseWithNoData,"Pattern discard not allowed for union case that takes no data." +3548,matchNotAllowedForUnionCaseWithNoData,"Pattern discard is not allowed for union case that takes no data." diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 2c2516d272..cd3a34b921 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -213,8 +213,8 @@ - Pattern match discard not allowed for union case that takes no data. - Pattern match discard not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. @@ -408,8 +408,8 @@ - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 007253ad4f..01a5cade73 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -213,8 +213,8 @@ - Pattern match discard not allowed for union case that takes no data. - Pattern match discard not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. @@ -408,8 +408,8 @@ - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 8623da2613..81faedb0e9 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -213,8 +213,8 @@ - Pattern match discard not allowed for union case that takes no data. - Pattern match discard not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. @@ -408,8 +408,8 @@ - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index aedc2f4761..366890f756 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -213,8 +213,8 @@ - Pattern match discard not allowed for union case that takes no data. - Pattern match discard not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. @@ -408,8 +408,8 @@ - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 4d7baf4a35..b9922d1694 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -213,8 +213,8 @@ - Pattern match discard not allowed for union case that takes no data. - Pattern match discard not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. @@ -408,8 +408,8 @@ - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 45d43b2e31..b711c9d9f3 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -213,8 +213,8 @@ - Pattern match discard not allowed for union case that takes no data. - Pattern match discard not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. @@ -408,8 +408,8 @@ - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 9318356fb9..40d1b9c30b 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -213,8 +213,8 @@ - Pattern match discard not allowed for union case that takes no data. - Pattern match discard not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. @@ -408,8 +408,8 @@ - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 7b3bb9a1eb..23d950d189 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -213,8 +213,8 @@ - Pattern match discard not allowed for union case that takes no data. - Pattern match discard not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. @@ -408,8 +408,8 @@ - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 7c94e3664f..2a6eb368be 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -213,8 +213,8 @@ - Pattern match discard not allowed for union case that takes no data. - Pattern match discard not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. @@ -408,8 +408,8 @@ - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index ac0b7019b7..3b4cafe834 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -213,8 +213,8 @@ - Pattern match discard not allowed for union case that takes no data. - Pattern match discard not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. @@ -408,8 +408,8 @@ - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index ba89d9f1d2..e0e4df0357 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -213,8 +213,8 @@ - Pattern match discard not allowed for union case that takes no data. - Pattern match discard not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. @@ -408,8 +408,8 @@ - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 9d55f7f0e4..10dc4f098c 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -213,8 +213,8 @@ - Pattern match discard not allowed for union case that takes no data. - Pattern match discard not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. @@ -408,8 +408,8 @@ - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 17846a8550..59f1848505 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -213,8 +213,8 @@ - Pattern match discard not allowed for union case that takes no data. - Pattern match discard not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. @@ -408,8 +408,8 @@ - Pattern discard not allowed for union case that takes no data. - Pattern discard not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data.