From 94bbbaa5acd34ac88bcc06b6235090ac6b47d6b6 Mon Sep 17 00:00:00 2001 From: Chet Husk Date: Thu, 10 Mar 2022 23:13:51 -0600 Subject: [PATCH 1/6] first try --- src/fsharp/CheckExpressions.fs | 8 +++++++- src/fsharp/FSComp.txt | 2 +- src/fsharp/xlf/FSComp.txt.cs.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.de.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.es.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.fr.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.it.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.ja.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.ko.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.pl.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.pt-BR.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.ru.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.tr.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.zh-Hans.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.zh-Hant.xlf | 4 ++-- 15 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/fsharp/CheckExpressions.fs b/src/fsharp/CheckExpressions.fs index f18059cbab1..7368daa63d3 100644 --- a/src/fsharp/CheckExpressions.fs +++ b/src/fsharp/CheckExpressions.fs @@ -5283,7 +5283,13 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv, names, takenNames) ty p elif numArgs < numArgTys then if numArgTys > 1 then // Expects tuple without enough args - errorR (Error (FSComp.SR.tcUnionCaseExpectsTupledArguments numArgTys, m)) + let missingArgs = + argNames.[numArgs..numArgTys - 1] + |> List.map (fun id -> id.idText) + |> String.concat "\n" + |> fun s -> "\n"+s + + errorR (Error (FSComp.SR.tcUnionCaseExpectsTupledArguments(numArgTys, missingArgs), m)) else errorR (UnionCaseWrongArguments (env.DisplayEnv, numArgTys, numArgs, m)) args @ (List.init (numArgTys - numArgs) (fun _ -> SynPat.Wild (m.MakeSynthetic()))), extraPatterns diff --git a/src/fsharp/FSComp.txt b/src/fsharp/FSComp.txt index 104473b2ec5..1a4df1fc1be 100644 --- a/src/fsharp/FSComp.txt +++ b/src/fsharp/FSComp.txt @@ -571,7 +571,7 @@ tcCouldNotFindIDisposable,"Couldn't find Dispose on IDisposable, or it was overl 724,tcInvalidIndexIntoActivePatternArray,"Internal error. Invalid index into active pattern array" 725,tcUnionCaseDoesNotTakeArguments,"This union case does not take arguments" 726,tcUnionCaseRequiresOneArgument,"This union case takes one argument" -727,tcUnionCaseExpectsTupledArguments,"This union case expects %d arguments in tupled form" +727,tcUnionCaseExpectsTupledArguments,"This union case expects %d arguments in tupled form. The missing arguments are :%s" 728,tcFieldIsNotStatic,"Field '%s' is not static" 729,tcFieldNotLiteralCannotBeUsedInPattern,"This field is not a literal and cannot be used in a pattern" 730,tcRequireVarConstRecogOrLiteral,"This is not a variable, constant, active recognizer or literal" diff --git a/src/fsharp/xlf/FSComp.txt.cs.xlf b/src/fsharp/xlf/FSComp.txt.cs.xlf index e62f2ee27c9..6b4812598f2 100644 --- a/src/fsharp/xlf/FSComp.txt.cs.xlf +++ b/src/fsharp/xlf/FSComp.txt.cs.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form - Tento případ typu union očekává argumenty v počtu {0} v podobě řazené kolekce členů. + This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form. The missing arguments are :{1} diff --git a/src/fsharp/xlf/FSComp.txt.de.xlf b/src/fsharp/xlf/FSComp.txt.de.xlf index ba127a65ab8..35e76d20bfd 100644 --- a/src/fsharp/xlf/FSComp.txt.de.xlf +++ b/src/fsharp/xlf/FSComp.txt.de.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form - Dieser Union-Fall erwartet {0} Argumente als Tupel. + This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form. The missing arguments are :{1} diff --git a/src/fsharp/xlf/FSComp.txt.es.xlf b/src/fsharp/xlf/FSComp.txt.es.xlf index c53f9a5af14..478d733c00c 100644 --- a/src/fsharp/xlf/FSComp.txt.es.xlf +++ b/src/fsharp/xlf/FSComp.txt.es.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form - Este caso de unión espera {0} argumentos en forma de tupla. + This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form. The missing arguments are :{1} diff --git a/src/fsharp/xlf/FSComp.txt.fr.xlf b/src/fsharp/xlf/FSComp.txt.fr.xlf index 7b1783dc3ed..86219c698b7 100644 --- a/src/fsharp/xlf/FSComp.txt.fr.xlf +++ b/src/fsharp/xlf/FSComp.txt.fr.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form - Ce cas d'union attend {0} arguments basés sur des tuples + This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form. The missing arguments are :{1} diff --git a/src/fsharp/xlf/FSComp.txt.it.xlf b/src/fsharp/xlf/FSComp.txt.it.xlf index 20f85121269..38e1a1db00d 100644 --- a/src/fsharp/xlf/FSComp.txt.it.xlf +++ b/src/fsharp/xlf/FSComp.txt.it.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form - Questo case di unione prevede {0} argomenti sotto forma di tupla + This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form. The missing arguments are :{1} diff --git a/src/fsharp/xlf/FSComp.txt.ja.xlf b/src/fsharp/xlf/FSComp.txt.ja.xlf index be9dfed2e2a..1e6d0665eee 100644 --- a/src/fsharp/xlf/FSComp.txt.ja.xlf +++ b/src/fsharp/xlf/FSComp.txt.ja.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form - この共用体ケースにはタプル形式の引数を {0} 個指定してください + This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form. The missing arguments are :{1} diff --git a/src/fsharp/xlf/FSComp.txt.ko.xlf b/src/fsharp/xlf/FSComp.txt.ko.xlf index 220ac33630b..c01080f28c7 100644 --- a/src/fsharp/xlf/FSComp.txt.ko.xlf +++ b/src/fsharp/xlf/FSComp.txt.ko.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form - 이 공용 구조체 케이스에는 튜플된 형식의 인수 {0}개가 필요합니다. + This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form. The missing arguments are :{1} diff --git a/src/fsharp/xlf/FSComp.txt.pl.xlf b/src/fsharp/xlf/FSComp.txt.pl.xlf index 8c20b84069f..acf5900e9e6 100644 --- a/src/fsharp/xlf/FSComp.txt.pl.xlf +++ b/src/fsharp/xlf/FSComp.txt.pl.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form - Ten przypadek unii oczekuje {0} argumentów w postaci spójnej kolekcji + This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form. The missing arguments are :{1} diff --git a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf index 0d8de614d17..c459113f98f 100644 --- a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf +++ b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form - Este caso união espera argumentos {0} na forma de tupla + This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form. The missing arguments are :{1} diff --git a/src/fsharp/xlf/FSComp.txt.ru.xlf b/src/fsharp/xlf/FSComp.txt.ru.xlf index 14372c25312..53d5c92103c 100644 --- a/src/fsharp/xlf/FSComp.txt.ru.xlf +++ b/src/fsharp/xlf/FSComp.txt.ru.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form - Для данного случая объединения требуется {0} аргументов в форме кортежа + This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form. The missing arguments are :{1} diff --git a/src/fsharp/xlf/FSComp.txt.tr.xlf b/src/fsharp/xlf/FSComp.txt.tr.xlf index 647ac274fb3..fb40e932ef2 100644 --- a/src/fsharp/xlf/FSComp.txt.tr.xlf +++ b/src/fsharp/xlf/FSComp.txt.tr.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form - Bu birleşim durumu grup olarak tanımlanmış biçimde {0} bağımsız değişken bekliyor + This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form. The missing arguments are :{1} diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf index a04b1d827ab..b9068777322 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form - 此联合用例需要 {0} 个元组格式的参数 + This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form. The missing arguments are :{1} diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf index 26e278c8709..7acf71aa225 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form - 這個聯集需要 {0} 個 Tuple 形式的引數 + This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form. The missing arguments are :{1} From 9bad9abb3324584dc4d05c7970ae2fc769e6bdd7 Mon Sep 17 00:00:00 2001 From: Chet Husk Date: Thu, 10 Mar 2022 23:36:01 -0600 Subject: [PATCH 2/6] better message --- src/fsharp/CheckExpressions.fs | 2 +- src/fsharp/FSComp.txt | 2 +- src/fsharp/xlf/FSComp.txt.cs.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.de.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.es.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.fr.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.it.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.ja.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.ko.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.pl.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.pt-BR.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.ru.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.tr.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.zh-Hans.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.zh-Hant.xlf | 4 ++-- 15 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/fsharp/CheckExpressions.fs b/src/fsharp/CheckExpressions.fs index 7368daa63d3..393fddda4f5 100644 --- a/src/fsharp/CheckExpressions.fs +++ b/src/fsharp/CheckExpressions.fs @@ -5289,7 +5289,7 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv, names, takenNames) ty p |> String.concat "\n" |> fun s -> "\n"+s - errorR (Error (FSComp.SR.tcUnionCaseExpectsTupledArguments(numArgTys, missingArgs), m)) + errorR (Error (FSComp.SR.tcUnionCaseExpectsTupledArguments(numArgTys, numArgs, missingArgs), m)) else errorR (UnionCaseWrongArguments (env.DisplayEnv, numArgTys, numArgs, m)) args @ (List.init (numArgTys - numArgs) (fun _ -> SynPat.Wild (m.MakeSynthetic()))), extraPatterns diff --git a/src/fsharp/FSComp.txt b/src/fsharp/FSComp.txt index 1a4df1fc1be..e9d441a229e 100644 --- a/src/fsharp/FSComp.txt +++ b/src/fsharp/FSComp.txt @@ -571,7 +571,7 @@ tcCouldNotFindIDisposable,"Couldn't find Dispose on IDisposable, or it was overl 724,tcInvalidIndexIntoActivePatternArray,"Internal error. Invalid index into active pattern array" 725,tcUnionCaseDoesNotTakeArguments,"This union case does not take arguments" 726,tcUnionCaseRequiresOneArgument,"This union case takes one argument" -727,tcUnionCaseExpectsTupledArguments,"This union case expects %d arguments in tupled form. The missing arguments are :%s" +727,tcUnionCaseExpectsTupledArguments,"This union case expects %d arguments in tupled form, but was only given %d. The missing arguments are:%s" 728,tcFieldIsNotStatic,"Field '%s' is not static" 729,tcFieldNotLiteralCannotBeUsedInPattern,"This field is not a literal and cannot be used in a pattern" 730,tcRequireVarConstRecogOrLiteral,"This is not a variable, constant, active recognizer or literal" diff --git a/src/fsharp/xlf/FSComp.txt.cs.xlf b/src/fsharp/xlf/FSComp.txt.cs.xlf index 6b4812598f2..91cc2057d1f 100644 --- a/src/fsharp/xlf/FSComp.txt.cs.xlf +++ b/src/fsharp/xlf/FSComp.txt.cs.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form. The missing arguments are :{1} - This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} diff --git a/src/fsharp/xlf/FSComp.txt.de.xlf b/src/fsharp/xlf/FSComp.txt.de.xlf index 35e76d20bfd..274dca0efc2 100644 --- a/src/fsharp/xlf/FSComp.txt.de.xlf +++ b/src/fsharp/xlf/FSComp.txt.de.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form. The missing arguments are :{1} - This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} diff --git a/src/fsharp/xlf/FSComp.txt.es.xlf b/src/fsharp/xlf/FSComp.txt.es.xlf index 478d733c00c..b067a43c871 100644 --- a/src/fsharp/xlf/FSComp.txt.es.xlf +++ b/src/fsharp/xlf/FSComp.txt.es.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form. The missing arguments are :{1} - This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} diff --git a/src/fsharp/xlf/FSComp.txt.fr.xlf b/src/fsharp/xlf/FSComp.txt.fr.xlf index 86219c698b7..5a8a5097854 100644 --- a/src/fsharp/xlf/FSComp.txt.fr.xlf +++ b/src/fsharp/xlf/FSComp.txt.fr.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form. The missing arguments are :{1} - This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} diff --git a/src/fsharp/xlf/FSComp.txt.it.xlf b/src/fsharp/xlf/FSComp.txt.it.xlf index 38e1a1db00d..90178f675bb 100644 --- a/src/fsharp/xlf/FSComp.txt.it.xlf +++ b/src/fsharp/xlf/FSComp.txt.it.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form. The missing arguments are :{1} - This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} diff --git a/src/fsharp/xlf/FSComp.txt.ja.xlf b/src/fsharp/xlf/FSComp.txt.ja.xlf index 1e6d0665eee..52b42ef4e1d 100644 --- a/src/fsharp/xlf/FSComp.txt.ja.xlf +++ b/src/fsharp/xlf/FSComp.txt.ja.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form. The missing arguments are :{1} - This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} diff --git a/src/fsharp/xlf/FSComp.txt.ko.xlf b/src/fsharp/xlf/FSComp.txt.ko.xlf index c01080f28c7..e9f69af07a3 100644 --- a/src/fsharp/xlf/FSComp.txt.ko.xlf +++ b/src/fsharp/xlf/FSComp.txt.ko.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form. The missing arguments are :{1} - This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} diff --git a/src/fsharp/xlf/FSComp.txt.pl.xlf b/src/fsharp/xlf/FSComp.txt.pl.xlf index acf5900e9e6..dd1a38b9b59 100644 --- a/src/fsharp/xlf/FSComp.txt.pl.xlf +++ b/src/fsharp/xlf/FSComp.txt.pl.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form. The missing arguments are :{1} - This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} diff --git a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf index c459113f98f..c222caf4671 100644 --- a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf +++ b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form. The missing arguments are :{1} - This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} diff --git a/src/fsharp/xlf/FSComp.txt.ru.xlf b/src/fsharp/xlf/FSComp.txt.ru.xlf index 53d5c92103c..dfe9e544710 100644 --- a/src/fsharp/xlf/FSComp.txt.ru.xlf +++ b/src/fsharp/xlf/FSComp.txt.ru.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form. The missing arguments are :{1} - This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} diff --git a/src/fsharp/xlf/FSComp.txt.tr.xlf b/src/fsharp/xlf/FSComp.txt.tr.xlf index fb40e932ef2..17c9cb9fce2 100644 --- a/src/fsharp/xlf/FSComp.txt.tr.xlf +++ b/src/fsharp/xlf/FSComp.txt.tr.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form. The missing arguments are :{1} - This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf index b9068777322..4f573c5ed29 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form. The missing arguments are :{1} - This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf index 7acf71aa225..77b47059b70 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form. The missing arguments are :{1} - This union case expects {0} arguments in tupled form. The missing arguments are :{1} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} From fa01817011a4ebe4f09273cd450ff7995c502798 Mon Sep 17 00:00:00 2001 From: Chet Husk Date: Fri, 11 Mar 2022 09:08:54 -0600 Subject: [PATCH 3/6] update message and test error message baselines --- src/fsharp/FSComp.txt | 2 +- src/fsharp/xlf/FSComp.txt.cs.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.de.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.es.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.fr.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.it.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.ja.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.ko.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.pl.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.pt-BR.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.ru.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.tr.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.zh-Hans.xlf | 4 ++-- src/fsharp/xlf/FSComp.txt.zh-Hant.xlf | 4 ++-- tests/service/PatternMatchCompilationTests.fs | 4 ++-- 15 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/fsharp/FSComp.txt b/src/fsharp/FSComp.txt index e9d441a229e..b3eec82e18d 100644 --- a/src/fsharp/FSComp.txt +++ b/src/fsharp/FSComp.txt @@ -571,7 +571,7 @@ tcCouldNotFindIDisposable,"Couldn't find Dispose on IDisposable, or it was overl 724,tcInvalidIndexIntoActivePatternArray,"Internal error. Invalid index into active pattern array" 725,tcUnionCaseDoesNotTakeArguments,"This union case does not take arguments" 726,tcUnionCaseRequiresOneArgument,"This union case takes one argument" -727,tcUnionCaseExpectsTupledArguments,"This union case expects %d arguments in tupled form, but was only given %d. The missing arguments are:%s" +727,tcUnionCaseExpectsTupledArguments,"This union case expects %d arguments in tupled form, but was given %d. The missing field arguments may be any of:%s" 728,tcFieldIsNotStatic,"Field '%s' is not static" 729,tcFieldNotLiteralCannotBeUsedInPattern,"This field is not a literal and cannot be used in a pattern" 730,tcRequireVarConstRecogOrLiteral,"This is not a variable, constant, active recognizer or literal" diff --git a/src/fsharp/xlf/FSComp.txt.cs.xlf b/src/fsharp/xlf/FSComp.txt.cs.xlf index 91cc2057d1f..0b1f55b6a15 100644 --- a/src/fsharp/xlf/FSComp.txt.cs.xlf +++ b/src/fsharp/xlf/FSComp.txt.cs.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} diff --git a/src/fsharp/xlf/FSComp.txt.de.xlf b/src/fsharp/xlf/FSComp.txt.de.xlf index 274dca0efc2..8faf90ddbb2 100644 --- a/src/fsharp/xlf/FSComp.txt.de.xlf +++ b/src/fsharp/xlf/FSComp.txt.de.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} diff --git a/src/fsharp/xlf/FSComp.txt.es.xlf b/src/fsharp/xlf/FSComp.txt.es.xlf index b067a43c871..a18c8bc7686 100644 --- a/src/fsharp/xlf/FSComp.txt.es.xlf +++ b/src/fsharp/xlf/FSComp.txt.es.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} diff --git a/src/fsharp/xlf/FSComp.txt.fr.xlf b/src/fsharp/xlf/FSComp.txt.fr.xlf index 5a8a5097854..374a45e8871 100644 --- a/src/fsharp/xlf/FSComp.txt.fr.xlf +++ b/src/fsharp/xlf/FSComp.txt.fr.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} diff --git a/src/fsharp/xlf/FSComp.txt.it.xlf b/src/fsharp/xlf/FSComp.txt.it.xlf index 90178f675bb..2a34cbf60ec 100644 --- a/src/fsharp/xlf/FSComp.txt.it.xlf +++ b/src/fsharp/xlf/FSComp.txt.it.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} diff --git a/src/fsharp/xlf/FSComp.txt.ja.xlf b/src/fsharp/xlf/FSComp.txt.ja.xlf index 52b42ef4e1d..917bbe7d0ba 100644 --- a/src/fsharp/xlf/FSComp.txt.ja.xlf +++ b/src/fsharp/xlf/FSComp.txt.ja.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} diff --git a/src/fsharp/xlf/FSComp.txt.ko.xlf b/src/fsharp/xlf/FSComp.txt.ko.xlf index e9f69af07a3..b249fa1be09 100644 --- a/src/fsharp/xlf/FSComp.txt.ko.xlf +++ b/src/fsharp/xlf/FSComp.txt.ko.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} diff --git a/src/fsharp/xlf/FSComp.txt.pl.xlf b/src/fsharp/xlf/FSComp.txt.pl.xlf index dd1a38b9b59..91b77fd8b75 100644 --- a/src/fsharp/xlf/FSComp.txt.pl.xlf +++ b/src/fsharp/xlf/FSComp.txt.pl.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} diff --git a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf index c222caf4671..8e8a8d1d783 100644 --- a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf +++ b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} diff --git a/src/fsharp/xlf/FSComp.txt.ru.xlf b/src/fsharp/xlf/FSComp.txt.ru.xlf index dfe9e544710..bd67d1e174e 100644 --- a/src/fsharp/xlf/FSComp.txt.ru.xlf +++ b/src/fsharp/xlf/FSComp.txt.ru.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} diff --git a/src/fsharp/xlf/FSComp.txt.tr.xlf b/src/fsharp/xlf/FSComp.txt.tr.xlf index 17c9cb9fce2..2b62d98e027 100644 --- a/src/fsharp/xlf/FSComp.txt.tr.xlf +++ b/src/fsharp/xlf/FSComp.txt.tr.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf index 4f573c5ed29..84c90a048a2 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf index 77b47059b70..49bcce7817d 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf @@ -3598,8 +3598,8 @@ - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} - This union case expects {0} arguments in tupled form, but was only given {1}. The missing arguments are:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} + This union case expects {0} arguments in tupled form, but was given {1}. The missing field arguments may be any of:{2} diff --git a/tests/service/PatternMatchCompilationTests.fs b/tests/service/PatternMatchCompilationTests.fs index c72d5bf25c3..2703ea28837 100644 --- a/tests/service/PatternMatchCompilationTests.fs +++ b/tests/service/PatternMatchCompilationTests.fs @@ -96,7 +96,7 @@ match A with """ assertHasSymbolUsages ["x"; "y"] checkResults dumpErrors checkResults |> shouldEqual [ - "(7,2--7,10): This union case expects 3 arguments in tupled form" + "(7,2--7,10): This union case expects 3 arguments in tupled form, but was given 2. The missing field arguments may be any of: Item3" "(6,6--6,7): Incomplete pattern matches on this expression. For example, the value 'A' may indicate a case not covered by the pattern(s)." ] @@ -233,7 +233,7 @@ match A with """ assertHasSymbolUsages ["x"; "y"; "z"] checkResults dumpErrors checkResults |> shouldEqual [ - "(7,2--7,7): This union case expects 2 arguments in tupled form" + "(7,2--7,7): This union case expects 2 arguments in tupled form, but was given 0. The missing field arguments may be any of: field Item2" "(6,6--6,7): Incomplete pattern matches on this expression. For example, the value 'A' may indicate a case not covered by the pattern(s)." ] From 1d5ee99f54be237969e214aae3736b78e3894045 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Mon, 26 Sep 2022 14:44:50 +0200 Subject: [PATCH 4/6] Printing tuples with * instead of , --- src/Compiler/Checking/CheckPatterns.fs | 7 ++++--- tests/service/PatternMatchCompilationTests.fs | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index a50ffed2a50..9dddf124a9f 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -678,11 +678,12 @@ and TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (m elif numArgs < numArgTys then if numArgTys > 1 then // Expects tuple without enough args + let printT = NicePrint.minimalStringOfType env.DisplayEnv let missingArgs = argNames.[numArgs..numArgTys - 1] - |> List.map (fun id -> (if id.rfield_name_generated then "" else id.DisplayName + ": ") + id.FormalType.ToString()) - |> String.concat "\n, " - |> fun s -> "\n"+s + |> List.map (fun id -> (if id.rfield_name_generated then "" else id.DisplayName + ": ") + printT id.FormalType) + |> String.concat (Environment.NewLine + ", ") + |> fun s -> Environment.NewLine+s errorR (Error (FSComp.SR.tcUnionCaseExpectsTupledArguments(numArgTys, numArgs, missingArgs), m)) else diff --git a/tests/service/PatternMatchCompilationTests.fs b/tests/service/PatternMatchCompilationTests.fs index 342b76b6673..a4ba884c8a5 100644 --- a/tests/service/PatternMatchCompilationTests.fs +++ b/tests/service/PatternMatchCompilationTests.fs @@ -256,14 +256,14 @@ match None with let ``Union case 10 - incomplete union fields`` () = let _, checkResults = getParseAndCheckResults """ type U = - | B of f1:int seq * {|X:string|} * f3:U + | B of f1:int seq * {|X:string|} * f3:U * f4: (int * System.String) let x : U = failwith "" match x with | B -> 42 """ dumpDiagnostics checkResults |> shouldEqual [ - "(7,2--7,3): This union case expects 3 arguments in tupled form, but was given 0. The missing field arguments may be any of: f1: seq , {|X string;|} , f3: U" + "(7,2--7,3): This union case expects 4 arguments in tupled form, but was given 0. The missing field arguments may be any of: f1: seq , {| X: string |} , f3: U , f4: (int * System.String)" ] [] From 4ece762ed527e8869e79446ffbc40ad438e19f85 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Mon, 26 Sep 2022 15:06:41 +0200 Subject: [PATCH 5/6] Replacing (newline + comma) with (newline + tab) for rendering lists of named types. --- src/Compiler/Checking/CheckPatterns.fs | 2 +- tests/service/PatternMatchCompilationTests.fs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index 9dddf124a9f..3fe03fbe923 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -682,7 +682,7 @@ and TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (m let missingArgs = argNames.[numArgs..numArgTys - 1] |> List.map (fun id -> (if id.rfield_name_generated then "" else id.DisplayName + ": ") + printT id.FormalType) - |> String.concat (Environment.NewLine + ", ") + |> String.concat (Environment.NewLine + "\t") |> fun s -> Environment.NewLine+s errorR (Error (FSComp.SR.tcUnionCaseExpectsTupledArguments(numArgTys, numArgs, missingArgs), m)) diff --git a/tests/service/PatternMatchCompilationTests.fs b/tests/service/PatternMatchCompilationTests.fs index a4ba884c8a5..e7557d3b9b0 100644 --- a/tests/service/PatternMatchCompilationTests.fs +++ b/tests/service/PatternMatchCompilationTests.fs @@ -233,7 +233,7 @@ match A with """ assertHasSymbolUsages ["x"; "y"; "z"] checkResults dumpDiagnostics checkResults |> shouldEqual [ - "(7,2--7,7): This union case expects 2 arguments in tupled form, but was given 0. The missing field arguments may be any of: field: int , int" + "(7,2--7,7): This union case expects 2 arguments in tupled form, but was given 0. The missing field arguments may be any of: field: int int" "(6,6--6,7): Incomplete pattern matches on this expression. For example, the value 'A' may indicate a case not covered by the pattern(s)." ] @@ -263,7 +263,7 @@ match x with | B -> 42 """ dumpDiagnostics checkResults |> shouldEqual [ - "(7,2--7,3): This union case expects 4 arguments in tupled form, but was given 0. The missing field arguments may be any of: f1: seq , {| X: string |} , f3: U , f4: (int * System.String)" + "(7,2--7,3): This union case expects 4 arguments in tupled form, but was given 0. The missing field arguments may be any of: f1: seq {| X: string |} f3: U f4: (int * System.String)" ] [] From 082b7c753e323b89d71a2edd849239928727fa19 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 27 Sep 2022 14:57:07 +0200 Subject: [PATCH 6/6] Moving tests to /ComponentTests --- src/Compiler/Checking/CheckPatterns.fs | 6 +- .../UnionCasePatternMatchingErrors.fs | 72 +++++++++++++++++ .../FSharp.Compiler.ComponentTests.fsproj | 1 + tests/service/PatternMatchCompilationTests.fs | 78 ------------------- 4 files changed, 76 insertions(+), 81 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index 3fe03fbe923..1e9c0418a18 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -678,12 +678,12 @@ and TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (m elif numArgs < numArgTys then if numArgTys > 1 then // Expects tuple without enough args - let printT = NicePrint.minimalStringOfType env.DisplayEnv + let printTy = NicePrint.minimalStringOfType env.DisplayEnv let missingArgs = argNames.[numArgs..numArgTys - 1] - |> List.map (fun id -> (if id.rfield_name_generated then "" else id.DisplayName + ": ") + printT id.FormalType) + |> List.map (fun id -> (if id.rfield_name_generated then "" else id.DisplayName + ": ") + printTy id.FormalType) |> String.concat (Environment.NewLine + "\t") - |> fun s -> Environment.NewLine+s + |> fun s -> Environment.NewLine + "\t" + s errorR (Error (FSComp.SR.tcUnionCaseExpectsTupledArguments(numArgTys, numArgs, missingArgs), m)) else diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs new file mode 100644 index 00000000000..b64dff5176c --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs @@ -0,0 +1,72 @@ +module FSharp.Compiler.ComponentTests.ErrorMessages.UnionCasePatternMatchingErrors + +open Xunit +open FSharp.Test.Compiler + +[] +let ``Union matching error - Incomplete union fields`` () = + FSharp """ +module Tests +type U = + | B of f1:int list * {|X:string|} * f3:U * f4: (int * System.String) + +let x : U = failwith "" +let myVal = + match x with + | B -> 42""" + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 727, Line 9, Col 7, Line 9, Col 8, + "This union case expects 4 arguments in tupled form, but was given 0. The missing field arguments may be any of: +\tf1: int list +\t{| X: string |} +\tf3: U +\tf4: (int * System.String)") + +[] +let ``Union matching error - Named args - Name used twice`` () = + FSharp """ +module Tests +type U = + | B of field: int * int +let x : U = failwith "" +let myVal = + match x with + | B (field = x; field = z) -> let y = x + z + 1 in ()""" + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 3175, Line 8, Col 21, Line 8, Col 26, "Union case/exception field 'field' cannot be used more than once.") + +[] +let ``Union matching error - Multiple tupled args`` () = + FSharp """ +module Tests +type U = + | B of field: int * int + +let x : U = failwith "" +let myVal = + match x with + | B x z -> let y = x + z + 1 in ()""" + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 727, Line 9, Col 7, Line 9, Col 12, "This union case expects 2 arguments in tupled form, but was given 0. The missing field arguments may be any of: +\tfield: int +\tint") + +[] +let ``Union matching error - Missing field`` () = + FSharp """ +module Tests +type U = + | A + | B of int * int * int + +let myVal = + match A with + | A -> 15 + | B (x, _) -> 16""" + |> 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 diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 4acda7d0cd7..3ef7efa769f 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -158,6 +158,7 @@ + diff --git a/tests/service/PatternMatchCompilationTests.fs b/tests/service/PatternMatchCompilationTests.fs index b0c70981c5c..7daef75bcf8 100644 --- a/tests/service/PatternMatchCompilationTests.fs +++ b/tests/service/PatternMatchCompilationTests.fs @@ -81,26 +81,6 @@ match 1, 2 with ] -[] -#if !NETCOREAPP -[] -#endif -let ``Union case 01 - Missing field`` () = - let _, checkResults = getParseAndCheckResults """ -type U = - | A - | B of int * int * int - -match A with -| B (x, _) -> let y = x + 1 in () -""" - assertHasSymbolUsages ["x"; "y"] checkResults - dumpDiagnostics checkResults |> shouldEqual [ - "(7,2--7,10): This union case expects 3 arguments in tupled form, but was given 2. The missing field arguments may be any of: int" - "(6,6--6,7): Incomplete pattern matches on this expression. For example, the value 'A' may indicate a case not covered by the pattern(s)." - ] - - [] #if !NETCOREAPP [] @@ -197,47 +177,6 @@ match A with "(6,6--6,7): Incomplete pattern matches on this expression. For example, the value 'A' may indicate a case not covered by the pattern(s)." ] - -[] -#if !NETCOREAPP -[] -#endif -let ``Union case 07 - Named args - Name used twice`` () = - let _, checkResults = getParseAndCheckResults """ -type U = - | A - | B of field: int * int - -match A with -| B (field = x; field = z) -> let y = x + z + 1 in () -""" - assertHasSymbolUsages ["x"; "y"; "z"] checkResults - dumpDiagnostics checkResults |> shouldEqual [ - "(7,16--7,21): Union case/exception field 'field' cannot be used more than once." - "(6,6--6,7): Incomplete pattern matches on this expression. For example, the value 'A' may indicate a case not covered by the pattern(s)." - ] - - -[] -#if !NETCOREAPP -[] -#endif -let ``Union case 08 - Multiple tupled args`` () = - let _, checkResults = getParseAndCheckResults """ -type U = - | A - | B of field: int * int - -match A with -| B x z -> let y = x + z + 1 in () -""" - assertHasSymbolUsages ["x"; "y"; "z"] checkResults - dumpDiagnostics checkResults |> shouldEqual [ - "(7,2--7,7): This union case expects 2 arguments in tupled form, but was given 0. The missing field arguments may be any of: field: int int" - "(6,6--6,7): Incomplete pattern matches on this expression. For example, the value 'A' may indicate a case not covered by the pattern(s)." - ] - - [] let ``Union case 09 - Single arg`` () = let _, checkResults = getParseAndCheckResults """ @@ -249,23 +188,6 @@ match None with dumpDiagnostics checkResults |> shouldEqual [ ] -[] -#if !NETCOREAPP -[] -#endif -let ``Union case 10 - incomplete union fields`` () = - let _, checkResults = getParseAndCheckResults """ -type U = - | B of f1:int seq * {|X:string|} * f3:U * f4: (int * System.String) - -let x : U = failwith "" -match x with -| B -> 42 -""" - dumpDiagnostics checkResults |> shouldEqual [ - "(7,2--7,3): This union case expects 4 arguments in tupled form, but was given 0. The missing field arguments may be any of: f1: seq {| X: string |} f3: U f4: (int * System.String)" - ] - [] #if !NETCOREAPP []