Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarfgp committed Oct 27, 2024
1 parent 1d3402a commit 724dc0b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
14 changes: 7 additions & 7 deletions src/Compiler/Checking/CheckPatterns.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -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.")
]
(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")
]
Original file line number Diff line number Diff line change
Expand Up @@ -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")
]
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,11 @@ type CustomerId = CustomerId of string
let customerId = CustomerId("123")

match customerId with
| CustomerId BBB -> ()
| 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"

0 comments on commit 724dc0b

Please sign in to comment.