@@ -5535,7 +5535,6 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv, names, takenNames) ty p
55355535 errorR (Error (FSComp.SR.tcUnionCaseDoesNotTakeArguments (), m))
55365536 [], args
55375537
5538-
55395538 | arg :: rest when numArgTys = 1 ->
55405539 if numArgTys = 1 && not (List.isEmpty rest) then
55415540 errorR (Error (FSComp.SR.tcUnionCaseRequiresOneArgument (), m))
@@ -5544,23 +5543,24 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv, names, takenNames) ty p
55445543 | [arg] -> [arg], []
55455544
55465545 | args ->
5547- errorR (Error (FSComp.SR.tcUnionCaseExpectsTupledArguments numArgTys, m))
55485546 [], args
55495547
55505548 let args, extraPatterns =
55515549 let numArgs = args.Length
55525550 if numArgs = numArgTys then
55535551 args, extraPatterns
5552+ elif numArgs < numArgTys then
5553+ if numArgTys > 1 then
5554+ // Expects tuple without enough args
5555+ errorR (Error (FSComp.SR.tcUnionCaseExpectsTupledArguments numArgTys, m))
5556+ else
5557+ errorR (UnionCaseWrongArguments (env.DisplayEnv, numArgTys, numArgs, m))
5558+ args @ (List.init (numArgTys - numArgs) (fun _ -> SynPat.Wild (m.MakeSynthetic()))), extraPatterns
55545559 else
5555- if numArgs < numArgTys then
5556- if numArgs <> 0 && numArgTys <> 0 then
5557- errorR (UnionCaseWrongArguments (env.DisplayEnv, numArgTys, numArgs, m))
5558- args @ (List.init (numArgTys - numArgs) (fun _ -> SynPat.Wild (m.MakeSynthetic()))), extraPatterns
5559- else
5560- let args, remaining = args |> List.splitAt numArgTys
5561- for remainingArg in remaining do
5562- errorR (UnionCaseWrongArguments (env.DisplayEnv, numArgTys, numArgs, remainingArg.Range))
5563- args, extraPatterns @ remaining
5560+ let args, remaining = args |> List.splitAt numArgTys
5561+ for remainingArg in remaining do
5562+ errorR (UnionCaseWrongArguments (env.DisplayEnv, numArgTys, numArgs, remainingArg.Range))
5563+ args, extraPatterns @ remaining
55645564
55655565 let extraPatterns = extraPatterns @ extraPatternsFromNames
55665566 let args', acc = TcPatterns warnOnUpper cenv env vFlags (tpenv, names, takenNames) argTys args
0 commit comments