From e583cf8a4baa15b5d03fb237e5556d2cfafffede Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 15 Oct 2025 15:23:52 +0200 Subject: [PATCH 1/7] Fix: warn FS0049 on upper union case labels --- src/Compiler/SyntaxTree/SyntaxTree.fs | 2 +- .../Conformance/PatternMatching/Union/Union.fs | 6 +++++- .../PatternMatching/Union/UpperUnionCasePattern.fs | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fs b/src/Compiler/SyntaxTree/SyntaxTree.fs index c41e483e27a..c41f2704c5f 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fs +++ b/src/Compiler/SyntaxTree/SyntaxTree.fs @@ -1057,7 +1057,7 @@ type SynMatchClause = member this.IsTrueMatchClause = let (SynMatchClause(trivia = trivia)) = this - trivia.BarRange.IsSome && trivia.ArrowRange.IsSome + trivia.ArrowRange.IsSome member this.Range = match this with diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs index 6aec715af30..7c5bdfb9b97 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs @@ -230,7 +230,9 @@ but here has type (Warning 49, Line 20, Col 7, Line 20, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); (Warning 49, Line 24, Col 3, Line 24, Col 6, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); (Warning 49, Line 28, Col 3, Line 28, Col 5, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 35, Col 14, Line 35, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.")] + (Warning 49, Line 35, Col 14, Line 35, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 37, Col 17, Line 37, Col 26, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 39, Col 15, Line 39, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] [] let ``Union - UpperUnionCasePattern_fs preview - --test:ErrorRanges`` compilation = @@ -252,4 +254,6 @@ but here has type (Warning 49, Line 24, Col 3, Line 24, Col 6, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") (Warning 49, Line 28, Col 3, Line 28, Col 5, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") (Warning 49, Line 35, Col 14, Line 35, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 37, Col 17, Line 37, Col 26, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 39, Col 15, Line 39, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs index 9d9715f87bf..15c5827a2bf 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs @@ -34,6 +34,10 @@ let customerId = CustomerId("123") match customerId with | CustomerId BBB -> () +match 42 with | UpperCase -> () + +match 42 with UpperCase -> () + type Record = { Name: string; Age: int } match { Name = "Alice"; Age = 30 } with From a7085880af169bd811faa52fb46719e92de734fe Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 15 Oct 2025 17:24:27 +0200 Subject: [PATCH 2/7] fix test --- .../Expressions/BindingExpressions/BindingExpressions.fs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs index 017e5b8a61f..94f8f88bdea 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs @@ -198,4 +198,7 @@ module BindingExpressions = |> asExe |> withOptions ["--test:ErrorRanges"] |> typecheck - |> shouldSucceed + |> shouldFail + |> withDiagnostics [ + (Warning 49, Line 61, Col 6, Line 61, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + ] From d5f4c64fbd629c6035beb96b66e8bca4663883d0 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 15 Oct 2025 21:07:17 +0200 Subject: [PATCH 3/7] Fix baselines --- tests/fsharp/typecheck/sigs/neg07.bsl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/fsharp/typecheck/sigs/neg07.bsl b/tests/fsharp/typecheck/sigs/neg07.bsl index 185b6393cfb..fe30f0548eb 100644 --- a/tests/fsharp/typecheck/sigs/neg07.bsl +++ b/tests/fsharp/typecheck/sigs/neg07.bsl @@ -1,3 +1,5 @@ +neg07.fs(7,10,7,29): typecheck error FS0049: Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name. + neg07.fs(24,13,24,23): typecheck error FS0039: The value or constructor 'UnionCase1' is not defined. Maybe you want one of the following: X.UnionCase1 From f2e7745636b5954de0a2081e7433ee1d6d7349e1 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 15 Oct 2025 21:40:59 +0200 Subject: [PATCH 4/7] more tests --- .../PatternMatching/Union/Union.fs | 45 ++++++++++++++++--- ...ePattern.fs => UpperUnionCasePattern01.fs} | 0 .../Union/UpperUnionCasePattern02.fs | 19 ++++++++ 3 files changed, 58 insertions(+), 6 deletions(-) rename tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/{UpperUnionCasePattern.fs => UpperUnionCasePattern01.fs} (100%) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern02.fs diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs index 7c5bdfb9b97..2b80da6bee5 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs @@ -211,8 +211,8 @@ but here has type (Warning 26, Line 8, Col 7, Line 8, Col 55, "This rule will never be matched") ] - [] - let ``Union - UpperUnionCasePattern_fs - --test:ErrorRanges`` compilation = + [] + let ``Union - UpperUnionCasePattern01_fs - --test:ErrorRanges`` compilation = compilation |> asFs |> withOptions ["--test:ErrorRanges"; "--nowarn:026"] @@ -233,9 +233,9 @@ but here has type (Warning 49, Line 35, Col 14, Line 35, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") (Warning 49, Line 37, Col 17, Line 37, Col 26, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") (Warning 49, Line 39, Col 15, Line 39, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] - - [] - let ``Union - UpperUnionCasePattern_fs preview - --test:ErrorRanges`` compilation = + + [] + let ``Union - UpperUnionCasePattern01_fs preview - --test:ErrorRanges`` compilation = compilation |> asFs |> withOptions ["--test:ErrorRanges"; "--nowarn:026"] @@ -256,4 +256,37 @@ but here has type (Warning 49, Line 35, Col 14, Line 35, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") (Warning 49, Line 37, Col 17, Line 37, Col 26, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") (Warning 49, Line 39, Col 15, Line 39, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - ] \ No newline at end of file + ] + + [] + let ``Union - UpperUnionCasePattern02_fs - --test:ErrorRanges`` compilation = + compilation + |> withLangVersion90 + |> asFs + |> withOptions ["--test:ErrorRanges"; "--nowarn:026"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 49, Line 4, Col 7, Line 4, Col 20, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 7, Col 18, Line 7, Col 31, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 9, Col 24, Line 9, Col 37, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 11, Col 22, Line 11, Col 35, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 15, Col 12, Line 15, Col 30, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 19, Col 10, Line 19, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + ] + + [] + let ``Union - UpperUnionCasePattern02_fs preview - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"; "--nowarn:026"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 49, Line 4, Col 7, Line 4, Col 20, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 7, Col 18, Line 7, Col 31, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 9, Col 24, Line 9, Col 37, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 11, Col 22, Line 11, Col 35, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 15, Col 12, Line 15, Col 30, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 19, Col 10, Line 19, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + ] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern01.fs similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs rename to tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern01.fs diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern02.fs new file mode 100644 index 00000000000..f3ab76ea877 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern02.fs @@ -0,0 +1,19 @@ + +let test1 x = + match x with + | UndefinedCase -> 1 + +let test2 x = + match x with UndefinedCase -> 1 + +let test3 = function | UndefinedCase -> 1 + +let test4 = function UndefinedCase -> 1 + +let test5 () = + try failwith "test" + with | UndefinedException -> 1 + +let test6 () = + try failwith "test" + with UndefinedException -> 1 \ No newline at end of file From 283fabd231b7d7a4d8769f66551991e3b3c19b2b Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 16 Oct 2025 09:08:51 +0200 Subject: [PATCH 5/7] Update TcPatUnnamedAs --- src/Compiler/Checking/CheckPatterns.fs | 13 ++++++++----- .../BindingExpressions/BindingExpressions.fs | 5 ++++- .../Conformance/PatternMatching/Union/Union.fs | 6 ++++++ .../Union/UpperUnionCasePattern02.fs | 10 +++++++++- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index eb61edf7eeb..1b456438f62 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -401,15 +401,18 @@ and TcPatNamedAs warnOnUpper cenv env valReprInfo vFlags patEnv ty synInnerPat i phase2, acc and TcPatUnnamedAs warnOnUpper cenv env vFlags patEnv ty pat1 pat2 m = - let pats = [pat1; pat2] - let warnOnUpper = + // Type-check pat1 with the original warnOnUpper flag (to warn on uppercase identifiers) + let pat1R, patEnv1 = TcPat warnOnUpper cenv env None vFlags patEnv ty pat1 + + // For pat2 (the binding variable like UppercaseIdentifier as Foo), suppress uppercase warnings if the feature is enabled + let warnOnUpperForPat2 = if cenv.g.langVersion.SupportsFeature(LanguageFeature.DontWarnOnUppercaseIdentifiersInBindingPatterns) then AllIdsOK else warnOnUpper - - let patsR, patEnvR = TcPatterns warnOnUpper cenv env vFlags patEnv (List.map (fun _ -> ty) pats) pats - let phase2 values = TPat_conjs(List.map (fun f -> f values) patsR, m) + + let pat2R, patEnvR = TcPat warnOnUpperForPat2 cenv env None vFlags patEnv1 ty pat2 + let phase2 values = TPat_conjs([pat1R values; pat2R values], m) phase2, patEnvR and TcPatNamed warnOnUpper cenv env vFlags patEnv id ty isMemberThis vis valReprInfo m = diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs index 94f8f88bdea..f5324a634f6 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs @@ -200,5 +200,8 @@ module BindingExpressions = |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 61, Col 6, Line 61, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 61, Col 6, Line 61, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 122, Col 6, Line 122, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 125, Col 6, Line 125, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 128, Col 6, Line 128, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs index 2b80da6bee5..c9d21ea73f2 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs @@ -273,6 +273,10 @@ but here has type (Warning 49, Line 11, Col 22, Line 11, Col 35, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") (Warning 49, Line 15, Col 12, Line 15, Col 30, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") (Warning 49, Line 19, Col 10, Line 19, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 23, Col 10, Line 23, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 23, Col 32, Line 23, Col 35, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 27, Col 12, Line 27, Col 30, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 27, Col 34, Line 27, Col 37, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] [] @@ -289,4 +293,6 @@ but here has type (Warning 49, Line 11, Col 22, Line 11, Col 35, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") (Warning 49, Line 15, Col 12, Line 15, Col 30, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") (Warning 49, Line 19, Col 10, Line 19, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 23, Col 10, Line 23, Col 28, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 27, Col 12, Line 27, Col 30, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern02.fs index f3ab76ea877..c04bae9035f 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern02.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern02.fs @@ -16,4 +16,12 @@ let test5 () = let test6 () = try failwith "test" - with UndefinedException -> 1 \ No newline at end of file + with UndefinedException -> 1 + +let test7 () = + try failwith "test" + with UndefinedException as Foo -> 1 + +let test8 () = + try failwith "test" + with | UndefinedException as Foo -> 1 \ No newline at end of file From ea20e4ddc7a54c57f3021b2e221a274c93b03ab9 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 16 Oct 2025 11:00:19 +0200 Subject: [PATCH 6/7] update tests --- .../PatternMatching/Union/Union.fs | 64 ++++++++++--------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs index c9d21ea73f2..18117c0e7f6 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs @@ -212,27 +212,28 @@ but here has type ] [] - let ``Union - UpperUnionCasePattern01_fs - --test:ErrorRanges`` compilation = + let ``Union - UpperUnionCasePattern01_fs LangVersion90 - --test:ErrorRanges`` compilation = compilation |> asFs + |> withLangVersion90 |> withOptions ["--test:ErrorRanges"; "--nowarn:026"] |> typecheck |> shouldFail - |> withDiagnostics - [(Warning 49, Line 3, Col 7, Line 3, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 4, Col 7, Line 4, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 5, Col 7, Line 5, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 9, Col 7, Line 9, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 10, Col 7, Line 10, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 11, Col 7, Line 11, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 15, Col 7, Line 15, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 16, Col 7, Line 16, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 20, Col 7, Line 20, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 24, Col 3, Line 24, Col 6, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 28, Col 3, Line 28, Col 5, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); - (Warning 49, Line 35, Col 14, Line 35, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 37, Col 17, Line 37, Col 26, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 39, Col 15, Line 39, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] + |> withDiagnostics [ + (Warning 49, Line 15, Col 7, Line 15, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 16, Col 7, Line 16, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 20, Col 7, Line 20, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 24, Col 3, Line 24, Col 6, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 35, Col 14, Line 35, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 37, Col 17, Line 37, Col 26, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 39, Col 15, Line 39, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 45, Col 12, Line 45, Col 15, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 49, Col 20, Line 49, Col 23, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 54, Col 14, Line 54, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 54, Col 21, Line 54, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 55, Col 14, Line 55, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 56, Col 14, Line 56, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + ] [] let ``Union - UpperUnionCasePattern01_fs preview - --test:ErrorRanges`` compilation = @@ -242,20 +243,23 @@ but here has type |> typecheck |> shouldFail |> withDiagnostics [ - (Warning 49, Line 3, Col 7, Line 3, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 4, Col 7, Line 4, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 5, Col 7, Line 5, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 9, Col 7, Line 9, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 10, Col 7, Line 10, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 11, Col 7, Line 11, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 15, Col 7, Line 15, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 16, Col 7, Line 16, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 20, Col 7, Line 20, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 24, Col 3, Line 24, Col 6, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 28, Col 3, Line 28, Col 5, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 35, Col 14, Line 35, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 37, Col 17, Line 37, Col 26, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") - (Warning 49, Line 39, Col 15, Line 39, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 3, Col 7, Line 3, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 4, Col 7, Line 4, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 5, Col 7, Line 5, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 9, Col 7, Line 9, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 10, Col 7, Line 10, Col 9, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 11, Col 7, Line 11, Col 8, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 15, Col 7, Line 15, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 16, Col 7, Line 16, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 20, Col 7, Line 20, Col 10, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 24, Col 3, Line 24, Col 6, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 28, Col 3, Line 28, Col 5, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 35, Col 14, Line 35, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 37, Col 17, Line 37, Col 26, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 39, Col 15, Line 39, Col 24, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 54, Col 14, Line 54, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 55, Col 14, Line 55, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name."); + (Warning 49, Line 56, Col 14, Line 56, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") ] [] From 49844bb8481b92177763c07b16f3bb4720663a77 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sat, 18 Oct 2025 11:52:31 +0200 Subject: [PATCH 7/7] release notes --- docs/release-notes/.FSharp.Compiler.Service/11.0.0.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/.FSharp.Compiler.Service/11.0.0.md b/docs/release-notes/.FSharp.Compiler.Service/11.0.0.md index 0469b0575f6..5ff739f3e13 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/11.0.0.md +++ b/docs/release-notes/.FSharp.Compiler.Service/11.0.0.md @@ -3,6 +3,7 @@ * Scripts: Fix resolving the dotnet host path when an SDK directory is specified. ([PR #18960](https://github.com/dotnet/fsharp/pull/18960)) * Fix excessive StackGuard thread jumping ([PR #18971](https://github.com/dotnet/fsharp/pull/18971)) * Fix name is bound multiple times is not reported in 'as' pattern ([PR #18984](https://github.com/dotnet/fsharp/pull/18984)) +* Fix: warn FS0049 on upper union case label. ([PR #19003](https://github.com/dotnet/fsharp/pull/19003)) ### Added