diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index abe1d46a4b8..ea6b56e021d 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -531,6 +531,11 @@ and TcPatLongIdent warnOnUpper cenv env ad valReprInfo vFlags (patEnv: TcPatLine TcPatLongIdentActivePatternCase warnOnUpper cenv env vFlags patEnv ty (mLongId, item, apref, args, m) | Item.UnionCase _ | Item.ExnCase _ as item -> + let warnOnUpper = + if cenv.g.langVersion.SupportsFeature(LanguageFeature.WarnOnUppercaseIdentifiersInPatterns) then + WarnOnUpperUnionCaseLabel + else warnOnUpper + TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (mLongId, item, args, m) | Item.ILField finfo -> @@ -718,15 +723,10 @@ and TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (m for remainingArg in remaining do errorR (UnionCaseWrongArguments (env.DisplayEnv, numArgTys, numArgs, remainingArg.Range)) args, extraPatterns @ remaining - - let warnOnUpperForId = - if g.langVersion.SupportsFeature(LanguageFeature.WarnOnUppercaseIdentifiersInPatterns) then - WarnOnUpperVariablePatterns - else warnOnUpper let extraPatterns = extraPatterns @ extraPatternsFromNames - let argsR, acc = TcPatterns warnOnUpperForId cenv env vFlags patEnv argTys args - let _, acc = TcPatterns warnOnUpperForId cenv env vFlags acc (NewInferenceTypes g extraPatterns) extraPatterns + let argsR, acc = TcPatterns warnOnUpper cenv env vFlags patEnv argTys args + let _, acc = TcPatterns warnOnUpper cenv env vFlags acc (NewInferenceTypes g extraPatterns) extraPatterns (fun values -> mkf m (List.map (fun f -> f values) argsR)), acc /// Check a long identifier that has been resolved to an IL field - valid if a literal diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs index 8d44801ec7d..ef70e2c2305 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/BindingExpressions/BindingExpressions.fs @@ -214,9 +214,9 @@ module BindingExpressions = (Warning 3874, Line 32, Col 25, Line 32, Col 28, "Variable patterns should be lowercase.") (Warning 3874, Line 34, Col 21, Line 34, Col 24, "Variable patterns should be lowercase.") (Warning 3874, Line 34, Col 25, Line 34, Col 28, "Variable patterns should be lowercase.") - (Warning 3874, Line 40, Col 17, Line 40, Col 20, "Variable patterns should be lowercase.") - (Warning 3874, Line 42, Col 31, Line 42, Col 34, "Variable patterns should be lowercase.") - (Warning 3874, Line 44, Col 32, Line 44, Col 34, "Variable patterns should be lowercase.") + (Warning 49, Line 40, Col 17, Line 40, Col 20, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 42, Col 31, Line 42, Col 34, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 44, Col 32, Line 44, Col 34, "Match cases labels must be lowercase identifiers") (Warning 3874, Line 46, Col 5, Line 46, Col 8, "Variable patterns should be lowercase.") (Warning 3874, Line 49, Col 5, Line 49, Col 7, "Variable patterns should be lowercase.") (Warning 3874, Line 53, Col 18, Line 53, Col 21, "Variable patterns should be lowercase.") @@ -231,8 +231,8 @@ module BindingExpressions = (Warning 3874, Line 95, Col 9, Line 95, Col 11, "Variable patterns should be lowercase.") (Warning 3874, Line 102, Col 9, Line 102, Col 11, "Variable patterns should be lowercase.") (Warning 3874, Line 109, Col 9, Line 109, Col 11, "Variable patterns should be lowercase.") - (Warning 3874, Line 117, Col 33, Line 117, Col 35, "Variable patterns should be lowercase.") - (Warning 3874, Line 117, Col 37, Line 117, Col 40, "Variable patterns should be lowercase.") - (Warning 3874, Line 119, Col 18, Line 119, Col 20, "Variable patterns should be lowercase.") - (Warning 3874, Line 119, Col 22, Line 119, Col 24, "Variable patterns should be lowercase.") - ] \ No newline at end of file + (Warning 49, Line 117, Col 33, Line 117, Col 35, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 117, Col 37, Line 117, Col 40, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 119, Col 18, Line 119, Col 20, "Match cases labels must be lowercase identifiers"); + (Warning 49, Line 119, Col 22, Line 119, Col 24, "Match cases labels must be lowercase identifiers") + ] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs index 7308f667601..41aca215752 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs @@ -247,4 +247,7 @@ but here has type (Warning 49, Line 24, Col 3, Line 24, Col 6, "Match cases labels must be lowercase identifiers") (Warning 49, Line 28, Col 3, Line 28, Col 5, "Match cases labels must be lowercase identifiers") (Warning 49, Line 35, Col 14, Line 35, Col 17, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 40, Col 12, Line 40, Col 14, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 41, Col 12, Line 41, Col 14, "Match cases labels must be lowercase identifiers") + (Warning 49, Line 42, Col 12, Line 42, Col 14, "Match cases labels must be lowercase identifiers") ] \ 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 41eb8ed5b9a..447a8faaa17 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/UpperUnionCasePattern.fs @@ -32,4 +32,11 @@ type CustomerId = CustomerId of string let customerId = CustomerId("123") match customerId with -| CustomerId BBB -> () \ No newline at end of file +| CustomerId BBB -> () + +type Record = { Name: string; Age: int } + +match { Name = "Alice"; Age = 30 } with +| { Name = Al } -> printfn "Alice" +| { Name = Bo } -> printfn "Bob" +| { Name = Pe } -> printfn "Pepe" \ No newline at end of file