From b64b0ada199226e0010ec5e34c76d52f15240ab2 Mon Sep 17 00:00:00 2001 From: ijklam Date: Sat, 9 Mar 2024 17:55:23 +0800 Subject: [PATCH 01/22] Add error FS3866 tcActivePatternArgumentCountNotMatch --- src/Compiler/Checking/CheckExpressions.fs | 33 ++++++++++++----------- src/Compiler/FSComp.txt | 3 ++- src/Compiler/xlf/FSComp.txt.cs.xlf | 5 ++++ src/Compiler/xlf/FSComp.txt.de.xlf | 5 ++++ src/Compiler/xlf/FSComp.txt.es.xlf | 5 ++++ src/Compiler/xlf/FSComp.txt.fr.xlf | 5 ++++ src/Compiler/xlf/FSComp.txt.it.xlf | 5 ++++ src/Compiler/xlf/FSComp.txt.ja.xlf | 5 ++++ src/Compiler/xlf/FSComp.txt.ko.xlf | 5 ++++ src/Compiler/xlf/FSComp.txt.pl.xlf | 5 ++++ src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 5 ++++ src/Compiler/xlf/FSComp.txt.ru.xlf | 5 ++++ src/Compiler/xlf/FSComp.txt.tr.xlf | 5 ++++ src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 5 ++++ src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 5 ++++ 15 files changed, 84 insertions(+), 17 deletions(-) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index f7e048223bf..8fda3ecce21 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -5124,22 +5124,23 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags let vExprTy = vExpr.Type let activePatArgsAsSynPats, patArg = - match args with - | [] -> [], SynPat.Const(SynConst.Unit, m) - | _ -> - // This bit of type-directed analysis ensures that parameterized partial active patterns returning unit do not need to take an argument - let dtys, retTy = stripFunTy g vExprTy - - if dtys.Length = args.Length + 1 && - ((isOptionTy g retTy && isUnitTy g (destOptionTy g retTy)) || - (isValueOptionTy g retTy && isUnitTy g (destValueOptionTy g retTy))) || - // `bool` partial AP always be treated as `unit option` - // For `val (|P|_|) : _ -> bool`, only allow `match x with | P -> ...` - // For `val (|P|_|) : _ -> _ -> bool`, only allow `match x with | P parameter -> ...` - (not apinfo.IsTotal && isBoolTy g retTy) then - args, SynPat.Const(SynConst.Unit, m) - else - List.frontAndBack args + // This bit of type-directed analysis ensures that parameterized partial active patterns returning unit do not need to take an argument + let dtys, retTy = stripFunTy g vExprTy + if (not apinfo.IsTotal && isBoolTy g retTy) then + checkLanguageFeatureError g.langVersion LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern m + if dtys.Length - 1 <> (args: _ list).Length then + errorR(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(dtys.Length - 1, 0, args.Length, 0), m)) + args, SynPat.Const(SynConst.Unit, m) + elif dtys.Length = args.Length + 1 && + ((isOptionTy g retTy && isUnitTy g (destOptionTy g retTy)) || + (isValueOptionTy g retTy && isUnitTy g (destValueOptionTy g retTy))) then + args, SynPat.Const(SynConst.Unit, m) + else + if dtys.Length > args.Length then + errorR(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(dtys.Length - 1, 1, args.Length, 0), m)) + elif dtys.Length < args.Length then + errorR(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(dtys.Length - 1, 1, args.Length - 1, 1), m)) + List.frontAndBack args if not (isNil activePatArgsAsSynPats) && apinfo.ActiveTags.Length <> 1 then errorR (Error (FSComp.SR.tcRequireActivePatternWithOneResult (), m)) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 5846712049b..c81731afab6 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1746,4 +1746,5 @@ featureReuseSameFieldsInStructUnions,"Share underlying fields in a [] di 3862,parsStaticMemberImcompleteSyntax,"Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration." 3863,parsExpectingField,"Expecting record field" 3864,tooManyMethodsInDotNetTypeWritingAssembly,"The type '%s' has too many methods. Found: '%d', maximum: '%d'" -3865,parsOnlySimplePatternsAreAllowedInConstructors,"Only simple patterns are allowed in primary constructors" \ No newline at end of file +3865,parsOnlySimplePatternsAreAllowedInConstructors,"Only simple patterns are allowed in primary constructors" +3866,tcActivePatternArgumentCountNotMatch,"This active pattern case needs %d argument(s) and %d return value, but here has %d argument(s) and %d return value." \ No newline at end of file diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 66205091123..33af3ecaad4 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -1112,6 +1112,11 @@ (Navržený název) + + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. Význam _ je tady nejednoznačný. Nelze ho použít pro proměnnou typu discard a zkratku funkce ve stejném oboru. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index f72b6948a76..898f36b0f16 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -1112,6 +1112,11 @@ (Empfohlener Name) + + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. Die Bedeutung von "_" ist hier mehrdeutig. Dieses Zeichen kann nicht in demselben Bereich für eine verworfene Variable und ein Funktionskürzel verwendet werden. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 12f4457f73e..f961df90aa2 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -1112,6 +1112,11 @@ (Nombre sugerido) + + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. El significado de _ es ambiguo aquí. No se puede usar para una variable descartada y una función abreviada en el mismo ámbito. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 9477b8b7680..e140fae796b 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -1112,6 +1112,11 @@ (Nom suggéré) + + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. La signification de _ est ici ambiguë. Il ne peut pas être utilisé pour une variable ignorée et un raccourci de fonction dans la même portée. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index b17ab37848d..e5770f7abd7 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -1112,6 +1112,11 @@ (Nome consigliato) + + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. Il significato di _ è ambiguo in questo contesto. Non può essere utilizzato per una variabile eliminata e una sintassi abbreviata di funzione nello stesso ambito. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index fa6fb18bda6..709cb60d488 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -1112,6 +1112,11 @@ (推奨される名前) + + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. ここでは _ の意味はあいまいです。破棄された変数と、同じスコープ内の関数の短縮形には使用できません。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 1cf38ecd52e..71027bcbed6 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -1112,6 +1112,11 @@ (제안된 이름) + + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. 여기서 _의 의미가 모호합니다. 삭제된 변수와 동일한 범위의 함수 줄임에는 사용할 수 없습니다. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index a36f1d7cb51..f3a07772c35 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -1112,6 +1112,11 @@ (Sugerowana nazwa) + + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. Znaczenie elementu _ jest tutaj niejednoznaczne. Nie można go użyć dla odrzuconej zmiennej i skrótu funkcji w tym samym zakresie. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 129e7cb792e..4a01883e6b8 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -1112,6 +1112,11 @@ (Nome sugerido) + + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. O significado de _ é ambíguo aqui. Ele não pode ser usado para uma variável descartada e uma abreviação de função no mesmo escopo. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index d0acf9ef585..8f9c6df894c 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -1112,6 +1112,11 @@ (предложенное имя) + + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. Неоднозначное значение символа _ здесь. Его нельзя использовать для пустой переменной и сокращенной функции в одной области. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 555f737153e..2f654efca24 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -1112,6 +1112,11 @@ (Önerilen ad) + + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. _ öğesinin anlamı burada belirsiz. Aynı kapsamda, atılan bir değişken ve işlev kısaltması için kullanılamaz. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 72e2ea8f447..5558bd2df6e 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -1112,6 +1112,11 @@ (建议名称) + + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. 此处的 _ 含义不明确。它不能用于同一范围内的已放弃变量和函数速记。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 817e803623b..eeb2f2af92e 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -1112,6 +1112,11 @@ (建議的名稱) + + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. 此處的 _ 意義不明確。它不能在同一個範圍中既作為已捨棄的變數又作為函式速記。 From 7eaab67e455754398d4477f7a4393924eba6a495 Mon Sep 17 00:00:00 2001 From: ijklam Date: Sat, 9 Mar 2024 18:43:03 +0800 Subject: [PATCH 02/22] fix: single case active pattern returning unit can omit return value --- src/Compiler/Checking/CheckExpressions.fs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index 8fda3ecce21..e7ea3ab0bcf 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -5126,6 +5126,7 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags let activePatArgsAsSynPats, patArg = // This bit of type-directed analysis ensures that parameterized partial active patterns returning unit do not need to take an argument let dtys, retTy = stripFunTy g vExprTy + if (not apinfo.IsTotal && isBoolTy g retTy) then checkLanguageFeatureError g.langVersion LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern m if dtys.Length - 1 <> (args: _ list).Length then @@ -5133,7 +5134,8 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags args, SynPat.Const(SynConst.Unit, m) elif dtys.Length = args.Length + 1 && ((isOptionTy g retTy && isUnitTy g (destOptionTy g retTy)) || - (isValueOptionTy g retTy && isUnitTy g (destValueOptionTy g retTy))) then + (isValueOptionTy g retTy && isUnitTy g (destValueOptionTy g retTy)) || + isUnitTy g retTy) then args, SynPat.Const(SynConst.Unit, m) else if dtys.Length > args.Length then From ba5ae8a11081e1f9c443ca96ba66910044efd7f9 Mon Sep 17 00:00:00 2001 From: ijklam Date: Sat, 9 Mar 2024 19:25:18 +0800 Subject: [PATCH 03/22] fix: Total AP case returning unit can omit unit --- src/Compiler/Checking/CheckExpressions.fs | 3 ++- src/Compiler/TypedTree/TypedTreeOps.fs | 21 +++++++++++++++++++++ src/Compiler/TypedTree/TypedTreeOps.fsi | 9 +++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index e7ea3ab0bcf..0cc9ec1afed 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -5135,7 +5135,8 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags elif dtys.Length = args.Length + 1 && ((isOptionTy g retTy && isUnitTy g (destOptionTy g retTy)) || (isValueOptionTy g retTy && isUnitTy g (destValueOptionTy g retTy)) || - isUnitTy g retTy) then + isUnitTy g retTy || + (isChoiceTy g retTy && isUnitTy g (destChoiceTy g retTy idx))) then args, SynPat.Const(SynConst.Unit, m) else if dtys.Length > args.Length then diff --git a/src/Compiler/TypedTree/TypedTreeOps.fs b/src/Compiler/TypedTree/TypedTreeOps.fs index 8001c049ece..83dcffcb4ea 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.fs @@ -3689,6 +3689,17 @@ let isOptionTy (g: TcGlobals) ty = | ValueNone -> false | ValueSome tcref -> tyconRefEq g g.option_tcr_canon tcref +let isChoiceTy (g: TcGlobals) ty = + match tryTcrefOfAppTy g ty with + | ValueNone -> false + | ValueSome tcref -> + tyconRefEq g g.choice2_tcr tcref || + tyconRefEq g g.choice3_tcr tcref || + tyconRefEq g g.choice4_tcr tcref || + tyconRefEq g g.choice5_tcr tcref || + tyconRefEq g g.choice6_tcr tcref || + tyconRefEq g g.choice7_tcr tcref + let tryDestOptionTy g ty = match argsOfAppTy g ty with | [ty1] when isOptionTy g ty -> ValueSome ty1 @@ -3699,6 +3710,11 @@ let tryDestValueOptionTy g ty = | [ty1] when isValueOptionTy g ty -> ValueSome ty1 | _ -> ValueNone +let tryDestChoiceTy g ty idx = + match argsOfAppTy g ty with + | ls when isChoiceTy g ty && ls.Length > idx -> ValueSome ls[idx] + | _ -> ValueNone + let destOptionTy g ty = match tryDestOptionTy g ty with | ValueSome ty -> ty @@ -3709,6 +3725,11 @@ let destValueOptionTy g ty = | ValueSome ty -> ty | ValueNone -> failwith "destValueOptionTy: not a value option type" +let destChoiceTy g ty idx = + match tryDestChoiceTy g ty idx with + | ValueSome ty -> ty + | ValueNone -> failwith "destChoiceTy: not a Choice type" + let isNullableTy (g: TcGlobals) ty = match tryTcrefOfAppTy g ty with | ValueNone -> false diff --git a/src/Compiler/TypedTree/TypedTreeOps.fsi b/src/Compiler/TypedTree/TypedTreeOps.fsi index 1154b7e8a01..6d1a1c7f6c3 100755 --- a/src/Compiler/TypedTree/TypedTreeOps.fsi +++ b/src/Compiler/TypedTree/TypedTreeOps.fsi @@ -1547,6 +1547,9 @@ val isValueOptionTy: TcGlobals -> TType -> bool /// Determine if a type is an option type val isOptionTy: TcGlobals -> TType -> bool +/// Determine if a type is an Choice type +val isChoiceTy: TcGlobals -> TType -> bool + /// Take apart an option type val destOptionTy: TcGlobals -> TType -> TType @@ -1556,6 +1559,12 @@ val tryDestOptionTy: TcGlobals -> TType -> TType voption /// Try to take apart an option type val destValueOptionTy: TcGlobals -> TType -> TType +/// Take apart an Choice type +val tryDestChoiceTy: TcGlobals -> TType -> int -> TType voption + +/// Try to take apart an Choice type +val destChoiceTy: TcGlobals -> TType -> int -> TType + /// Determine is a type is a System.Nullable type val isNullableTy: TcGlobals -> TType -> bool From c5cf6d432d256475e85deed180a7b998a063bb0f Mon Sep 17 00:00:00 2001 From: ijklam Date: Sat, 9 Mar 2024 20:14:23 +0800 Subject: [PATCH 04/22] fix: allow omit last argument when return type of the case not solve --- src/Compiler/Checking/CheckExpressions.fs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index 0cc9ec1afed..dc613493d1a 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -5132,12 +5132,22 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags if dtys.Length - 1 <> (args: _ list).Length then errorR(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(dtys.Length - 1, 0, args.Length, 0), m)) args, SynPat.Const(SynConst.Unit, m) - elif dtys.Length = args.Length + 1 && - ((isOptionTy g retTy && isUnitTy g (destOptionTy g retTy)) || - (isValueOptionTy g retTy && isUnitTy g (destValueOptionTy g retTy)) || - isUnitTy g retTy || - (isChoiceTy g retTy && isUnitTy g (destChoiceTy g retTy idx))) then - args, SynPat.Const(SynConst.Unit, m) + elif dtys.Length = args.Length + 1 then + let IsNotSolved ty = + match ty with + | TType_var(v, _) -> not v.IsSolved + | _ -> false + + let caseRetTy = + if isOptionTy g retTy then destOptionTy g retTy + elif isValueOptionTy g retTy then destValueOptionTy g retTy + elif isChoiceTy g retTy then destChoiceTy g retTy idx + else retTy + + if not (isUnitTy g caseRetTy || IsNotSolved caseRetTy) then + errorR(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(dtys.Length - 1, 1, args.Length, 0), m)) + + args, SynPat.Const(SynConst.Unit, m) else if dtys.Length > args.Length then errorR(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(dtys.Length - 1, 1, args.Length, 0), m)) From a1fbf13a67a3df7446b6e80eea6a8f775fe92fdd Mon Sep 17 00:00:00 2001 From: ijklam Date: Sat, 9 Mar 2024 22:07:00 +0800 Subject: [PATCH 05/22] try fix test --- src/Compiler/Checking/CheckExpressions.fs | 41 +++++++++++-------- ...rnTypeDirectedPartialActivePatternTests.fs | 24 ++--------- 2 files changed, 28 insertions(+), 37 deletions(-) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index dc613493d1a..71fea41a162 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -5124,35 +5124,44 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags let vExprTy = vExpr.Type let activePatArgsAsSynPats, patArg = + let rec IsNotSolved ty = + match ty with + | TType_var(v, _) when v.IsSolved -> + match v.Solution with + | Some t -> IsNotSolved t + | None -> false + | TType_var _ -> true + | _ -> false + // This bit of type-directed analysis ensures that parameterized partial active patterns returning unit do not need to take an argument let dtys, retTy = stripFunTy g vExprTy + let paramCount = if dtys.Length = 0 then 0 else dtys.Length - 1 if (not apinfo.IsTotal && isBoolTy g retTy) then checkLanguageFeatureError g.langVersion LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern m - if dtys.Length - 1 <> (args: _ list).Length then - errorR(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(dtys.Length - 1, 0, args.Length, 0), m)) - args, SynPat.Const(SynConst.Unit, m) - elif dtys.Length = args.Length + 1 then - let IsNotSolved ty = - match ty with - | TType_var(v, _) -> not v.IsSolved - | _ -> false + if paramCount = (args: _ list).Length then + args, SynPat.Const(SynConst.Unit, m) + else + error(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(paramCount, 0, args.Length, 0), m)) + elif paramCount = args.Length then let caseRetTy = if isOptionTy g retTy then destOptionTy g retTy elif isValueOptionTy g retTy then destValueOptionTy g retTy elif isChoiceTy g retTy then destChoiceTy g retTy idx else retTy - if not (isUnitTy g caseRetTy || IsNotSolved caseRetTy) then - errorR(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(dtys.Length - 1, 1, args.Length, 0), m)) - - args, SynPat.Const(SynConst.Unit, m) + if isUnitTy g caseRetTy || IsNotSolved caseRetTy then + args, SynPat.Const(SynConst.Unit, m) + else + error(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(paramCount, 1, args.Length, 0), m)) + elif IsNotSolved vExprTy then + List.frontAndBack args + elif dtys.Length > args.Length then + error(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(paramCount, 1, args.Length, 0), m)) + elif dtys.Length < args.Length then + error(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(paramCount, 1, args.Length - 1, 1), m)) else - if dtys.Length > args.Length then - errorR(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(dtys.Length - 1, 1, args.Length, 0), m)) - elif dtys.Length < args.Length then - errorR(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(dtys.Length - 1, 1, args.Length - 1, 1), m)) List.frontAndBack args if not (isNil activePatArgsAsSynPats) && apinfo.ActiveTags.Length <> 1 then diff --git a/tests/FSharp.Compiler.ComponentTests/Language/BooleanReturningAndReturnTypeDirectedPartialActivePatternTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/BooleanReturningAndReturnTypeDirectedPartialActivePatternTests.fs index ce630714e64..9a52f519e89 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/BooleanReturningAndReturnTypeDirectedPartialActivePatternTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/BooleanReturningAndReturnTypeDirectedPartialActivePatternTests.fs @@ -93,25 +93,7 @@ match "A" with |> typecheck |> shouldFail |> withDiagnostics [ - (Error 1, Line 4, Col 3, Line 4, Col 13, - "This expression was expected to have type - 'string -> bool' -but here has type - 'bool' ") - (Error 39, Line 4, Col 7, Line 4, Col 13, - "The value or constructor 'result' is not defined. Maybe you want one of the following: - Result") - (Error 1, Line 8, Col 3, Line 8, Col 13, - "This expression was expected to have type - 'string -> bool' -but here has type - 'bool' ") - (Error 39, Line 8, Col 7, Line 8, Col 13, - "The value or constructor 'result' is not defined. Maybe you want one of the following: - Result") - (Error 1, Line 12, Col 3, Line 12, Col 30, - "This expression was expected to have type - 'string -> bool' -but here has type - 'bool' ") + (Error 3866, Line 4, Col 3, Line 4, Col 13, "This active pattern case needs 0 argument(s) and 0 return value, but here has 1 argument(s) and 0 return value.") + (Error 3866, Line 8, Col 3, Line 8, Col 13, "This active pattern case needs 0 argument(s) and 0 return value, but here has 1 argument(s) and 0 return value.") + (Error 3866, Line 12, Col 3, Line 12, Col 30, "This active pattern case needs 0 argument(s) and 0 return value, but here has 1 argument(s) and 0 return value.") ] From 53cb3010178c453e7a7ff1f1e1f080c0b8236bbd Mon Sep 17 00:00:00 2001 From: ijklam Date: Tue, 12 Mar 2024 02:12:01 +0800 Subject: [PATCH 06/22] try fix test 2 --- src/Compiler/Checking/CheckExpressions.fs | 28 ++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index 71fea41a162..37140d1a280 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -5134,9 +5134,22 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags | _ -> false // This bit of type-directed analysis ensures that parameterized partial active patterns returning unit do not need to take an argument - let dtys, retTy = stripFunTy g vExprTy + let dtys, retTy = + let rec loop g ty = + if isFunTy g ty then + let domainTy, rangeTy = destFunTy g ty + if isFunTy g domainTy then + domainTy :: [], rangeTy + else + let more, retTy = loop g rangeTy + domainTy :: more, retTy + else [], ty + + loop g vExprTy + let paramCount = if dtys.Length = 0 then 0 else dtys.Length - 1 + // partial active pattern (returning bool) doesn't have output arg if (not apinfo.IsTotal && isBoolTy g retTy) then checkLanguageFeatureError g.langVersion LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern m if paramCount = (args: _ list).Length then @@ -5144,7 +5157,8 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags else error(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(paramCount, 0, args.Length, 0), m)) - elif paramCount = args.Length then + // active pattern (not single case, returning unit or 'Boxed) can omit output arg + elif (not apinfo.IsTotal || apinfo.ActiveTags.Length > 1) && paramCount = args.Length then let caseRetTy = if isOptionTy g retTy then destOptionTy g retTy elif isValueOptionTy g retTy then destValueOptionTy g retTy @@ -5155,8 +5169,16 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags args, SynPat.Const(SynConst.Unit, m) else error(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(paramCount, 1, args.Length, 0), m)) - elif IsNotSolved vExprTy then + + // single case active pattern (1 input, returning unit) can omit output arg + elif paramCount = args.Length && paramCount = 0 then + args, SynPat.Const(SynConst.Unit, m) + + // active pattern (returning unknown things) can not omit output arg + elif IsNotSolved vExprTy then List.frontAndBack args + + // active pattern (returning 'a or 'Boxed<'a>) can not omit output arg elif dtys.Length > args.Length then error(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(paramCount, 1, args.Length, 0), m)) elif dtys.Length < args.Length then From ae7f35789f1176fc472ca56948c35693a9e47f32 Mon Sep 17 00:00:00 2001 From: ijklam Date: Tue, 12 Mar 2024 02:50:39 +0800 Subject: [PATCH 07/22] Change way to get parameter count --- src/Compiler/Checking/CheckExpressions.fs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index 37140d1a280..a249299fcbc 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -5133,20 +5133,12 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags | TType_var _ -> true | _ -> false + let valReprInfo = + match vref.ValReprInfo with + | None -> ValReprInfo.emptyValData + | Some info -> info // This bit of type-directed analysis ensures that parameterized partial active patterns returning unit do not need to take an argument - let dtys, retTy = - let rec loop g ty = - if isFunTy g ty then - let domainTy, rangeTy = destFunTy g ty - if isFunTy g domainTy then - domainTy :: [], rangeTy - else - let more, retTy = loop g rangeTy - domainTy :: more, retTy - else [], ty - - loop g vExprTy - + let dtys, retTy = GetTopTauTypeInFSharpForm g valReprInfo.ArgInfos vExprTy m let paramCount = if dtys.Length = 0 then 0 else dtys.Length - 1 // partial active pattern (returning bool) doesn't have output arg From fbe1bec1cfcfba3e88c58b9dcfebbcfe4c3ea253 Mon Sep 17 00:00:00 2001 From: ijklam Date: Tue, 12 Mar 2024 04:16:27 +0800 Subject: [PATCH 08/22] try fix 3 --- src/Compiler/Checking/CheckExpressions.fs | 29 ++++++++++++++--------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index a249299fcbc..1fa4f4bd895 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -5132,14 +5132,20 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags | None -> false | TType_var _ -> true | _ -> false + let canOmit retTy = isUnitTy g retTy || IsNotSolved retTy + // This bit of type-directed analysis ensures that parameterized partial active patterns returning unit do not need to take an argument + let dtys, retTy = stripFunTy g vExprTy + let paramCount = if dtys.Length = 0 then 0 else dtys.Length - 1 + + // "real" paramCount and retTy + // doesn't take (_ -> _) -> (_ -> _) as (_ -> _) -> _ -> _ let valReprInfo = match vref.ValReprInfo with | None -> ValReprInfo.emptyValData | Some info -> info - // This bit of type-directed analysis ensures that parameterized partial active patterns returning unit do not need to take an argument - let dtys, retTy = GetTopTauTypeInFSharpForm g valReprInfo.ArgInfos vExprTy m - let paramCount = if dtys.Length = 0 then 0 else dtys.Length - 1 + let dtysReal, retTyReal = GetTopTauTypeInFSharpForm g valReprInfo.ArgInfos vExprTy m + let paramCountReal = if dtysReal.Length = 0 then 0 else dtysReal.Length - 1 // partial active pattern (returning bool) doesn't have output arg if (not apinfo.IsTotal && isBoolTy g retTy) then @@ -5149,27 +5155,28 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags else error(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(paramCount, 0, args.Length, 0), m)) - // active pattern (not single case, returning unit or 'Boxed) can omit output arg - elif (not apinfo.IsTotal || apinfo.ActiveTags.Length > 1) && paramCount = args.Length then + // check single case active pattern use real paramCount and retTy + elif apinfo.IsTotal && apinfo.ActiveTags.Length = 1 && paramCountReal = args.Length && canOmit retTyReal then + args, SynPat.Const(SynConst.Unit, m) + elif apinfo.IsTotal && apinfo.ActiveTags.Length = 1 && dtysReal.Length = args.Length then + List.frontAndBack args + + // active pattern (returning unit or 'Boxed) can omit output arg + elif paramCount = args.Length then let caseRetTy = if isOptionTy g retTy then destOptionTy g retTy elif isValueOptionTy g retTy then destValueOptionTy g retTy elif isChoiceTy g retTy then destChoiceTy g retTy idx else retTy - if isUnitTy g caseRetTy || IsNotSolved caseRetTy then + if canOmit caseRetTy then args, SynPat.Const(SynConst.Unit, m) else error(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(paramCount, 1, args.Length, 0), m)) - // single case active pattern (1 input, returning unit) can omit output arg - elif paramCount = args.Length && paramCount = 0 then - args, SynPat.Const(SynConst.Unit, m) - // active pattern (returning unknown things) can not omit output arg elif IsNotSolved vExprTy then List.frontAndBack args - // active pattern (returning 'a or 'Boxed<'a>) can not omit output arg elif dtys.Length > args.Length then error(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(paramCount, 1, args.Length, 0), m)) From eecce1d01dbe099b084ab76bd016d5504fd75164 Mon Sep 17 00:00:00 2001 From: ijklam Date: Tue, 12 Mar 2024 05:56:51 +0800 Subject: [PATCH 09/22] single case: allow all dtys.Length >= args.Length --- src/Compiler/Checking/CheckExpressions.fs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index 1fa4f4bd895..7d26638c4fe 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -5138,15 +5138,6 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags let dtys, retTy = stripFunTy g vExprTy let paramCount = if dtys.Length = 0 then 0 else dtys.Length - 1 - // "real" paramCount and retTy - // doesn't take (_ -> _) -> (_ -> _) as (_ -> _) -> _ -> _ - let valReprInfo = - match vref.ValReprInfo with - | None -> ValReprInfo.emptyValData - | Some info -> info - let dtysReal, retTyReal = GetTopTauTypeInFSharpForm g valReprInfo.ArgInfos vExprTy m - let paramCountReal = if dtysReal.Length = 0 then 0 else dtysReal.Length - 1 - // partial active pattern (returning bool) doesn't have output arg if (not apinfo.IsTotal && isBoolTy g retTy) then checkLanguageFeatureError g.langVersion LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern m @@ -5155,10 +5146,9 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags else error(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(paramCount, 0, args.Length, 0), m)) - // check single case active pattern use real paramCount and retTy - elif apinfo.IsTotal && apinfo.ActiveTags.Length = 1 && paramCountReal = args.Length && canOmit retTyReal then - args, SynPat.Const(SynConst.Unit, m) - elif apinfo.IsTotal && apinfo.ActiveTags.Length = 1 && dtysReal.Length = args.Length then + // for single case active pattern, if not all parameter provided, output will be a function + // that takes the remaining parameter as input + elif apinfo.IsTotal && apinfo.ActiveTags.Length = 1 && dtys.Length >= args.Length && not args.IsEmpty then List.frontAndBack args // active pattern (returning unit or 'Boxed) can omit output arg @@ -5169,6 +5159,7 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags elif isChoiceTy g retTy then destChoiceTy g retTy idx else retTy + // only 0 parameter single case active pattern can omit output arg if canOmit caseRetTy then args, SynPat.Const(SynConst.Unit, m) else @@ -5177,6 +5168,7 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags // active pattern (returning unknown things) can not omit output arg elif IsNotSolved vExprTy then List.frontAndBack args + // active pattern (returning 'a or 'Boxed<'a>) can not omit output arg elif dtys.Length > args.Length then error(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(paramCount, 1, args.Length, 0), m)) From d4f8e178caca1a7a04e2ec2cef977b7035f24a28 Mon Sep 17 00:00:00 2001 From: ijklam Date: Tue, 12 Mar 2024 07:27:28 +0800 Subject: [PATCH 10/22] update release note --- docs/release-notes/.FSharp.Compiler.Service/8.0.300.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md index f14715ddf7c..f52b351a23b 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md @@ -38,3 +38,4 @@ * Refactored parenthesization API. ([PR #16461])(https://github.com/dotnet/fsharp/pull/16461)) * Optimize some interpolated strings by lowering to string concatenation. ([PR #16556](https://github.com/dotnet/fsharp/pull/16556)) * Integral range optimizations. ([PR #16650](https://github.com/dotnet/fsharp/pull/16650)) +* Add error tcActivePatternArgumentCountNotMatch ([PR #16846](https://github.com/dotnet/fsharp/pull/16846)) \ No newline at end of file From 77c416625f14b4a1d4a173df83ba0c0b89ac62ee Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Mon, 8 Apr 2024 18:13:30 +0800 Subject: [PATCH 11/22] divide the msg by whether with params --- src/Compiler/Checking/CheckExpressions.fs | 12 ++++++++---- src/Compiler/FSComp.txt | 3 ++- src/Compiler/xlf/FSComp.txt.cs.xlf | 9 +++++++-- src/Compiler/xlf/FSComp.txt.de.xlf | 9 +++++++-- src/Compiler/xlf/FSComp.txt.es.xlf | 9 +++++++-- src/Compiler/xlf/FSComp.txt.fr.xlf | 9 +++++++-- src/Compiler/xlf/FSComp.txt.it.xlf | 9 +++++++-- src/Compiler/xlf/FSComp.txt.ja.xlf | 9 +++++++-- src/Compiler/xlf/FSComp.txt.ko.xlf | 9 +++++++-- src/Compiler/xlf/FSComp.txt.pl.xlf | 9 +++++++-- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 9 +++++++-- src/Compiler/xlf/FSComp.txt.ru.xlf | 9 +++++++-- src/Compiler/xlf/FSComp.txt.tr.xlf | 9 +++++++-- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 9 +++++++-- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 9 +++++++-- ...AndReturnTypeDirectedPartialActivePatternTests.fs | 6 +++--- 16 files changed, 104 insertions(+), 34 deletions(-) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index 02a44e9c9d4..3bd36058384 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -5138,13 +5138,17 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags let dtys, retTy = stripFunTy g vExprTy let paramCount = if dtys.Length = 0 then 0 else dtys.Length - 1 + let showErrMsg returnCount actualParamCount actualReturnCount = + if paramCount = 0 then error(Error(FSComp.SR.tcNoParameterActivePatternArgumentCountNotMatch(returnCount, actualParamCount + actualReturnCount), m)) + else error(Error(FSComp.SR.tcParameterizedActivePatternArgumentCountNotMatch(paramCount, returnCount, actualParamCount, actualReturnCount), m)) + // partial active pattern (returning bool) doesn't have output arg if (not apinfo.IsTotal && isBoolTy g retTy) then checkLanguageFeatureError g.langVersion LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern m if paramCount = (args: _ list).Length then args, SynPat.Const(SynConst.Unit, m) else - error(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(paramCount, 0, args.Length, 0), m)) + showErrMsg 0 args.Length 0 // for single case active pattern, if not all parameter provided, output will be a function // that takes the remaining parameter as input @@ -5163,7 +5167,7 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags if canOmit caseRetTy then args, SynPat.Const(SynConst.Unit, m) else - error(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(paramCount, 1, args.Length, 0), m)) + showErrMsg 1 args.Length 0 // active pattern (returning unknown things) can not omit output arg elif IsNotSolved vExprTy then @@ -5171,9 +5175,9 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags // active pattern (returning 'a or 'Boxed<'a>) can not omit output arg elif dtys.Length > args.Length then - error(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(paramCount, 1, args.Length, 0), m)) + showErrMsg 1 args.Length 0 elif dtys.Length < args.Length then - error(Error(FSComp.SR.tcActivePatternArgumentCountNotMatch(paramCount, 1, args.Length - 1, 1), m)) + showErrMsg 1 (args.Length - 1) 1 else List.frontAndBack args diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index aed46162adc..6139bbb9fdd 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1745,4 +1745,5 @@ featureReuseSameFieldsInStructUnions,"Share underlying fields in a [] di 3863,parsExpectingField,"Expecting record field" 3864,tooManyMethodsInDotNetTypeWritingAssembly,"The type '%s' has too many methods. Found: '%d', maximum: '%d'" 3865,parsOnlySimplePatternsAreAllowedInConstructors,"Only simple patterns are allowed in primary constructors" -3866,tcActivePatternArgumentCountNotMatch,"This active pattern case needs %d argument(s) and %d return value, but here has %d argument(s) and %d return value." \ No newline at end of file +3866,tcParameterizedActivePatternArgumentCountNotMatch,"This active pattern requires %d parameter(s) and returns %d value(s), but the usage here matches %d argument(s) and %d return value(s)." +3867,tcNoParameterActivePatternArgumentCountNotMatch,"This active pattern returns %d value(s), but the usage here matches %d return value(s)." \ No newline at end of file diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 9c201f09a5f..e807c591404 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -1108,8 +1108,8 @@ - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). @@ -1382,6 +1382,11 @@ Toto přepsání přebírá řazenou kolekci členů místo více argumentů. Zkuste do definice metody přidat další vrstvu závorek, např. member _. Foo((x, y)) nebo odeberte závorky v deklaraci abstraktní metody (např. 'abstract member Foo: 'a * 'b -> 'c'). + + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + + The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. Syntaxe (expr1)[expr2] je při použití jako argument nejednoznačná. Více informací: https://aka.ms/fsharp-index-notation. Pokud plánujete indexování nebo vytváření řezů, musíte použít (expr1).[expr2] na pozici argumentu. Pokud voláte funkci s vícenásobnými curryfikovanými argumenty, přidejte mezi ně mezeru, třeba someFunction (expr1) [expr2]. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index d7893beff69..81ee80670ce 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -1108,8 +1108,8 @@ - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). @@ -1382,6 +1382,11 @@ Diese Außerkraftsetzung akzeptiert ein Tupel anstelle mehrerer Argumente. Fügen Sie der Methodendefinition eine zusätzliche Ebene von Klammern hinzu (z. B. "member _. Foo((x, y))"), oder entfernen Sie Klammern in der abstrakten Methodendeklaration (z. B. "abstract member Foo: 'a * 'b -> 'c"). + + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + + The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. Die Syntax "(expr1)[expr2]" ist mehrdeutig, wenn sie als Argument verwendet wird. Siehe https://aka.ms/fsharp-index-notation. Wenn Sie indizieren oder aufteilen möchten, müssen Sie "(expr1).[expr2]' in Argumentposition verwenden. Wenn Sie eine Funktion mit mehreren geschweiften Argumenten aufrufen, fügen Sie ein Leerzeichen dazwischen hinzu, z. B. "someFunction (expr1) [expr2]". diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index fd61383a9b9..28331afdee8 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -1108,8 +1108,8 @@ - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). @@ -1382,6 +1382,11 @@ Esta invalidación toma una tupla en lugar de varios argumentos. Intente agregar una capa adicional de paréntesis en la definición del método (por ejemplo, “member _. Foo((x, y))”) o quitar paréntesis en la declaración de método abstracto (por ejemplo, “abstract member Foo: “a * “b -> “c”). + + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + + The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. La sintaxis "(expr1)[expr2]" es ambigua cuando se usa como argumento. Vea https://aka.ms/fsharp-index-notation. Si piensa indexar o segmentar, debe usar "(expr1).[expr2]" en la posición del argumento. Si se llama a una función con varios argumentos currificados, se agregará un espacio entre ellos, por ejemplo, "unaFunción (expr1) [expr2]". diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 25d14ad19dd..27f64cea529 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -1108,8 +1108,8 @@ - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). @@ -1382,6 +1382,11 @@ Ce remplacement prend un tuple au lieu de plusieurs arguments. Essayez d'ajouter une couche supplémentaire de parenthèses à la définition de la méthode (par exemple 'member _.Foo((x, y))'), ou supprimez les parenthèses au niveau de la déclaration de la méthode abstraite (par exemple 'abstract member Foo: 'a * 'b -> 'c'). + + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + + The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. La syntaxe « (expr1)[expr2] » est ambiguë lorsqu’elle est utilisée comme argument. Voir https://aka.ms/fsharp-index-notation. Si vous avez l’intention d’indexer ou de découper, vous devez utiliser « (expr1).[expr2] » en position d’argument. Si vous appelez une fonction avec plusieurs arguments codés, ajoutez un espace entre eux, par exemple « someFunction (expr1) [expr2] ». diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index ba69a0cd62f..4cad3aa9369 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -1108,8 +1108,8 @@ - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). @@ -1382,6 +1382,11 @@ Questa sostituzione accetta una tupla anziché più argomenti. Prova ad aggiungere un ulteriore livello di parentesi alla definizione del metodo (ad esempio 'member _.Foo((x, y))') o rimuovi le parentesi nella dichiarazione del metodo astratto (ad esempio, 'abstract member Foo: 'a * 'b -> 'c'). + + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + + The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. La sintassi '(expr1)[expr2]' è ambigua se usata come argomento. Vedere https://aka.ms/fsharp-index-notation. Se si intende eseguire l'indicizzazione o il sezionamento, è necessario usare '(expr1).[expr2]' nella posizione dell'argomento. Se si chiama una funzione con più argomenti sottoposti a corsi, aggiungere uno spazio tra di essi, ad esempio 'someFunction (expr1) [expr2]'. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 36bc09b9f31..f7050f45c91 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -1108,8 +1108,8 @@ - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). @@ -1382,6 +1382,11 @@ このオーバーライドは、複数の引数ではなくタプルを受け取ります。メソッド定義にかっこのレイヤーを追加してみるか (例: 'member _.Foo((x, y))')、または抽象メソッド宣言でかっこを削除します (例: 'abstract member Foo: 'a * 'b -> 'c')。 + + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + + The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. 構文 '(expr1)[expr2]' は引数として使用されている場合、あいまいです。https://aka.ms/fsharp-index-notation を参照してください。インデックス作成またはスライスを行う場合は、'(expr1).[expr2]' を引数の位置に使用する必要があります。複数のカリー化された引数を持つ関数を呼び出す場合は、'someFunction (expr1) [expr2]' のように間にスペースを追加します。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index e17a9292f71..d9de39918a5 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -1108,8 +1108,8 @@ - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). @@ -1382,6 +1382,11 @@ 이 재정의는 여러 인수 대신 튜플을 사용합니다. 메서드 정의에 괄호 계층을 더 추가하거나(예: 'member _.Foo((x, y))') 추상 메서드 선언에서 괄호를 제거하세요(예: 'abstract member Foo: 'a * 'b -> 'c'). + + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + + The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. '(expr1)[expr2]' 구문은 인수로 사용될 때 모호합니다. https://aka.ms/fsharp-index-notation을 참조하세요. 인덱싱이나 슬라이싱을 하려면 인수 위치에 '(expr1).[expr2]'를 사용해야 합니다. 여러 개의 커리된 인수로 함수를 호출하는 경우 그 사이에 공백을 추가하세요(예: 'someFunction (expr1) [expr2]'). diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 1965922bd6b..7b42834be5c 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -1108,8 +1108,8 @@ - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). @@ -1382,6 +1382,11 @@ To zastąpienie przyjmuje krotki zamiast wielu argumentów. Spróbuj dodać dodatkową warstwę nawiasów w definicji metody (np. „member _. Foo((x, y))”) lub usuń nawiasy w deklaracji metody abstrakcyjnej (np. „abstract member Foo: „a * ”b -> „c”). + + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + + The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. Składnia wyrażenia „(expr1)[expr2]” jest niejednoznaczna, gdy jest używana jako argument. Zobacz https://aka.ms/fsharp-index-notation. Jeśli zamierzasz indeksować lub fragmentować, to w pozycji argumentu musi być użyte wyrażenie „(expr1).[expr2]”. Jeśli wywołujesz funkcję z wieloma argumentami typu curried, dodaj spację między nimi, np. „someFunction (expr1) [expr2]”. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 07cf2824566..9c79c763e71 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -1108,8 +1108,8 @@ - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). @@ -1382,6 +1382,11 @@ Essa substituição usa uma tupla em vez de vários argumentos. Tente adicionar uma camada adicional de parênteses na definição do método (por exemplo, "member _. Foo((x, y))") ou remova os parênteses na declaração de método abstrato (por exemplo, "membro abstrato Foo: 'a * 'b -> 'c"). + + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + + The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. A sintaxe '[expr1][expr2]' é ambígua quando usada como um argumento. Consulte https://aka.ms/fsharp-index-notation. Se você pretende indexar ou colocar em fatias, deve usar '(expr1).[expr2]' na posição do argumento. Se chamar uma função com vários argumentos na forma curried, adicione um espaço entre eles, por exemplo, 'someFunction [expr1] [expr2]'. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index c127f14e92e..32c15736df0 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -1108,8 +1108,8 @@ - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). @@ -1382,6 +1382,11 @@ Это переопределение принимает кортеж вместо нескольких аргументов. Попробуйте добавить дополнительный слой круглых скобок в определении метода (например, "member _.Foo((x, y))") или удалить круглые скобки в объявлении абстрактного метода (например, "abstract member Foo: "a * "b -> "c"). + + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + + The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. Синтаксис "(expr1)[expr2]" неоднозначен при использовании в качестве аргумента. См. https://aka.ms/fsharp-index-notation. Если вы намереваетесь индексировать или разрезать, необходимо использовать "(expr1).[expr2]" в позиции аргумента. При вызове функции с несколькими каррированными аргументами добавьте пробел между ними, например "someFunction (expr1) [expr2]". diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index fea097e7d7f..641cf0f66c0 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -1108,8 +1108,8 @@ - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). @@ -1382,6 +1382,11 @@ Bu geçersiz kılma, birden çok bağımsız değişken yerine bir tanımlama grubu alır. Metot tanımına ek bir parantez katmanı (ör. 'member _. Foo((x, y)')) eklemeyi deneyin veya soyut yöntem bildirimindeki parantezleri kaldırın (ör. 'abstract member Foo: 'a * 'b -> 'c'). + + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + + The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. Söz dizimi “(expr1)[expr2]” bağımsız değişken olarak kullanıldığında belirsizdir. https://aka.ms/fsharp-index-notation'a bakın. Dizin oluşturmayı veya dilimlemeyi düşünüyorsanız, bağımsız değişken konumunda “(expr1).[expr2]” kullanmalısınız. Birden çok curry bağımsız değişkenli bir işlev çağırıyorsanız, aralarına bir boşluk ekleyin, örn. “someFunction (expr1) [expr2]”. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index f5c08d5709e..08825bce9ca 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -1108,8 +1108,8 @@ - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). @@ -1382,6 +1382,11 @@ 此重写采用元组而不是多个参数。请尝试在方法定义中添加额外的括号层(例如 'member _.Foo((x, y))'),或在抽象方法声明中删除括号 (例如 'abstract member Foo: 'a * 'b -> 'c')。 + + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + + The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. 语法“(expr1)[expr2]”用作参数时不明确。请参阅 https://aka.ms/fsharp-index-notation。如果要索引或切片,则必须在参数位置使用“(expr1)[expr2]”。如果使用多个扩充参数调用函数,请在它们之间添加空格,例如“someFunction (expr1)[expr2]”。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index a45a0115e66..6cc0b034dc3 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -1108,8 +1108,8 @@ - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. - This active pattern case needs {0} argument(s) and {1} return value, but here has {2} argument(s) and {3} return value. + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). @@ -1382,6 +1382,11 @@ 此覆寫接受一個元組,而不是多個引數。請嘗試在方法定義中新增額外一層括弧 (例如 'member _.Foo((x, y))'),或在抽象方法宣告中移除括弧 (例如 'abstract member Foo: 'a * 'b -> 'c')。 + + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). + + The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. 語法 '(expr1)[expr2]' 用作引數時不明確。請參閱 https://aka.ms/fsharp-index-notation。如果您要編製索引或切割,則必須在引數位置使用 '(expr1).[expr2]'。如果要呼叫具有多個調用引數的函式,請在它們之間新增空格,例如 'someFunction (expr1) [expr2]'。 diff --git a/tests/FSharp.Compiler.ComponentTests/Language/BooleanReturningAndReturnTypeDirectedPartialActivePatternTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/BooleanReturningAndReturnTypeDirectedPartialActivePatternTests.fs index 9a52f519e89..8c86abd3856 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/BooleanReturningAndReturnTypeDirectedPartialActivePatternTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/BooleanReturningAndReturnTypeDirectedPartialActivePatternTests.fs @@ -93,7 +93,7 @@ match "A" with |> typecheck |> shouldFail |> withDiagnostics [ - (Error 3866, Line 4, Col 3, Line 4, Col 13, "This active pattern case needs 0 argument(s) and 0 return value, but here has 1 argument(s) and 0 return value.") - (Error 3866, Line 8, Col 3, Line 8, Col 13, "This active pattern case needs 0 argument(s) and 0 return value, but here has 1 argument(s) and 0 return value.") - (Error 3866, Line 12, Col 3, Line 12, Col 30, "This active pattern case needs 0 argument(s) and 0 return value, but here has 1 argument(s) and 0 return value.") + (Error 3867, Line 4, Col 3, Line 4, Col 13, "This active pattern returns 0 value(s), but the usage here matches 1 return value(s).") + (Error 3867, Line 8, Col 3, Line 8, Col 13, "This active pattern returns 0 value(s), but the usage here matches 1 return value(s).") + (Error 3867, Line 12, Col 3, Line 12, Col 30, "This active pattern returns 0 value(s), but the usage here matches 1 return value(s).") ] From d2dd62287d7ae01f06a8ac2c2fec092b86a7528d Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Tue, 9 Apr 2024 12:35:45 +0800 Subject: [PATCH 12/22] fix test --- ...ngAndReturnTypeDirectedPartialActivePatternTests.fs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Language/BooleanReturningAndReturnTypeDirectedPartialActivePatternTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/BooleanReturningAndReturnTypeDirectedPartialActivePatternTests.fs index 8c86abd3856..18570ebb76a 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/BooleanReturningAndReturnTypeDirectedPartialActivePatternTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/BooleanReturningAndReturnTypeDirectedPartialActivePatternTests.fs @@ -75,7 +75,8 @@ let (|OddVOption|_|) x = if x % 2 = 1 then ValueSome() else ValueNone [] let ``Can not receive result from bool active pattern`` () = - FSharp """let (|IsA|_|) x = x = "A" + FSharp """#nowarn "20" +let (|IsA|_|) x = x = "A" match "A" with | IsA result -> "A" @@ -93,7 +94,8 @@ match "A" with |> typecheck |> shouldFail |> withDiagnostics [ - (Error 3867, Line 4, Col 3, Line 4, Col 13, "This active pattern returns 0 value(s), but the usage here matches 1 return value(s).") - (Error 3867, Line 8, Col 3, Line 8, Col 13, "This active pattern returns 0 value(s), but the usage here matches 1 return value(s).") - (Error 3867, Line 12, Col 3, Line 12, Col 30, "This active pattern returns 0 value(s), but the usage here matches 1 return value(s).") + (Error 3867, Line 5, Col 3, Line 5, Col 13, "This active pattern returns 0 value(s), but the usage here matches 1 return value(s).") + (Error 3867, Line 9, Col 3, Line 9, Col 13, "This active pattern returns 0 value(s), but the usage here matches 1 return value(s).") + (Error 0039, Line 9, Col 17, Line 9, Col 23, "The value or constructor 'result' is not defined. Maybe you want one of the following: Result") + (Error 3867, Line 13, Col 3, Line 13, Col 30, "This active pattern returns 0 value(s), but the usage here matches 1 return value(s).") ] From 664bd41251f2c243b2ecf14a19337c27609a8089 Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Tue, 9 Apr 2024 14:07:04 +0800 Subject: [PATCH 13/22] typo --- ...nReturningAndReturnTypeDirectedPartialActivePatternTests.fs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Language/BooleanReturningAndReturnTypeDirectedPartialActivePatternTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/BooleanReturningAndReturnTypeDirectedPartialActivePatternTests.fs index 18570ebb76a..a8260ceed12 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/BooleanReturningAndReturnTypeDirectedPartialActivePatternTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/BooleanReturningAndReturnTypeDirectedPartialActivePatternTests.fs @@ -96,6 +96,7 @@ match "A" with |> withDiagnostics [ (Error 3867, Line 5, Col 3, Line 5, Col 13, "This active pattern returns 0 value(s), but the usage here matches 1 return value(s).") (Error 3867, Line 9, Col 3, Line 9, Col 13, "This active pattern returns 0 value(s), but the usage here matches 1 return value(s).") - (Error 0039, Line 9, Col 17, Line 9, Col 23, "The value or constructor 'result' is not defined. Maybe you want one of the following: Result") + (Error 0039, Line 9, Col 17, Line 9, Col 23, "The value or constructor 'result' is not defined. Maybe you want one of the following: + Result") (Error 3867, Line 13, Col 3, Line 13, Col 30, "This active pattern returns 0 value(s), but the usage here matches 1 return value(s).") ] From bbc2cee8da1618241c05770f805af6fbbe3b5f60 Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Tue, 9 Apr 2024 16:27:21 +0800 Subject: [PATCH 14/22] update xlf --- src/Compiler/xlf/FSComp.txt.cs.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.de.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.es.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.fr.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.it.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.ja.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.ko.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.pl.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.ru.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.tr.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 10 +++++----- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 10 +++++----- 13 files changed, 65 insertions(+), 65 deletions(-) diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 88f36a95f3e..c886f952a02 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -1112,11 +1112,6 @@ (Navržený název) - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. Význam _ je tady nejednoznačný. Nelze ho použít pro proměnnou typu discard a zkratku funkce ve stejném oboru. @@ -1342,6 +1337,11 @@ Použití metod s atributem NoEagerConstraintApplicationAttribute vyžaduje /langversion:6.0 nebo novější. + + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + + No static abstract member was found that corresponds to this override Nenašla se žádný statický abstraktní člen, který by odpovídal tomuto přepsání. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 5f107bb048e..c7ff5b9c1d0 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -1112,11 +1112,6 @@ (Empfohlener Name) - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. Die Bedeutung von "_" ist hier mehrdeutig. Dieses Zeichen kann nicht in demselben Bereich für eine verworfene Variable und ein Funktionskürzel verwendet werden. @@ -1342,6 +1337,11 @@ Die Verwendung von Methoden mit "NoEagerConstraintApplicationAttribute" erfordert /langversion:6.0 oder höher. + + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + + No static abstract member was found that corresponds to this override Es wurde kein abstrakter Member gefunden, der dieser Überschreibung entspricht. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 3434e9648e4..e11934fe511 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -1112,11 +1112,6 @@ (Nombre sugerido) - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. El significado de _ es ambiguo aquí. No se puede usar para una variable descartada y una función abreviada en el mismo ámbito. @@ -1342,6 +1337,11 @@ El uso de métodos con "NoEagerConstraintApplicationAttribute" requiere /langversion:6.0 o posteriores + + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + + No static abstract member was found that corresponds to this override No se encontró ningún miembro abstracto estático que corresponda a esta invalidación. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 3397b6edc18..c0100abc4fa 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -1112,11 +1112,6 @@ (Nom suggéré) - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. La signification de _ est ici ambiguë. Il ne peut pas être utilisé pour une variable ignorée et un raccourci de fonction dans la même portée. @@ -1342,6 +1337,11 @@ L’utilisation de méthodes avec « NoEagerConstraintApplicationAttribute » requiert/langversion:6.0 ou ultérieur + + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + + No static abstract member was found that corresponds to this override Désolé, nous n’avons pas pu trouver un membre abstrait statique qui corresponde à cette substitution diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 0fb8a2c996e..2fb14f6e67f 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -1112,11 +1112,6 @@ (Nome consigliato) - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. Il significato di _ è ambiguo in questo contesto. Non può essere utilizzato per una variabile eliminata e una sintassi abbreviata di funzione nello stesso ambito. @@ -1342,6 +1337,11 @@ L'utilizzo di metodi con 'NoEagerConstraintApplicationAttribute' richiede /langversion: 6.0 o versione successiva + + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + + No static abstract member was found that corresponds to this override Nessun membro astratto statico trovato corrispondente all'override diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index d26cc7969c4..30258a15059 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -1112,11 +1112,6 @@ (推奨される名前) - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. ここでは _ の意味はあいまいです。破棄された変数と、同じスコープ内の関数の短縮形には使用できません。 @@ -1342,6 +1337,11 @@ 'NoEagerConstraintApplicationAttribute' を指定してメソッドを使用するには、/langversion:6.0 以降が必要です + + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + + No static abstract member was found that corresponds to this override このオーバーライドに対応する静的抽象メンバーが見つかりませんでした diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index b24eb6f2007..988d5f57a8c 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -1112,11 +1112,6 @@ (제안된 이름) - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. 여기서 _의 의미가 모호합니다. 삭제된 변수와 동일한 범위의 함수 줄임에는 사용할 수 없습니다. @@ -1342,6 +1337,11 @@ 'NoEagerConstraintApplicationAttribute'와 함께 메서드를 사용하려면 /langversion:6.0 이상이 필요합니다. + + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + + No static abstract member was found that corresponds to this override 이 재정의에 해당하는 정적 추상 멤버를 찾을 수 없습니다. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index dbf19fe4d9b..5f75d999032 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -1112,11 +1112,6 @@ (Sugerowana nazwa) - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. Znaczenie elementu _ jest tutaj niejednoznaczne. Nie można go użyć dla odrzuconej zmiennej i skrótu funkcji w tym samym zakresie. @@ -1342,6 +1337,11 @@ Używanie metod z atrybutem "NoEagerConstraintApplicationAttribute" wymaga parametru /langversion:6.0 lub nowszego + + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + + No static abstract member was found that corresponds to this override Nie odnaleziono żadnego statycznego abstrakcyjnego elementu członkowskiego odpowiadającego temu przesłonięciu diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 7cca0892bbd..e2d2a7d2dbb 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -1112,11 +1112,6 @@ (Nome sugerido) - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. O significado de _ é ambíguo aqui. Ele não pode ser usado para uma variável descartada e uma abreviação de função no mesmo escopo. @@ -1342,6 +1337,11 @@ Usar métodos com 'NoEagerConstraintApplicationAttribute' requer /langversion:6.0 ou posterior + + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + + No static abstract member was found that corresponds to this override Nenhum membro abstrato estático encontrado que corresponda a esta substituição diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 18610491792..6ad23cee058 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -1112,11 +1112,6 @@ (предложенное имя) - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. Неоднозначное значение символа _ здесь. Его нельзя использовать для пустой переменной и сокращенной функции в одной области. @@ -1342,6 +1337,11 @@ Для использования методов с "NoEagerConstraintApplicationAttribute" требуется /langversion:6.0 или более поздняя версия + + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + + No static abstract member was found that corresponds to this override Не найден статический абстрактный элемент, соответствующий этому переопределению. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index d3966d19e05..9d8c7dc1bf4 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -1112,11 +1112,6 @@ (Önerilen ad) - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. _ öğesinin anlamı burada belirsiz. Aynı kapsamda, atılan bir değişken ve işlev kısaltması için kullanılamaz. @@ -1342,6 +1337,11 @@ 'NoEagerConstraintApplicationAttribute' içeren yöntemlerin kullanılması /langversion:6.0 veya üstünü gerektiriyor + + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + + No static abstract member was found that corresponds to this override Bu geçersiz kılmaya karşılık gelen hiçbir statik soyut üye bulunamadı diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 5ded51f082c..f88b5989055 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -1112,11 +1112,6 @@ (建议名称) - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. 此处的 _ 含义不明确。它不能用于同一范围内的已放弃变量和函数速记。 @@ -1342,6 +1337,11 @@ 将方法与 “NoEagerConstraintApplicationAttribute” 配合使用需要 /langversion:6.0 或更高版本 + + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + + No static abstract member was found that corresponds to this override 找不到与此替代对应的静态抽象成员 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index c2045945bdb..5b8fa41f202 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -1112,11 +1112,6 @@ (建議的名稱) - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. 此處的 _ 意義不明確。它不能在同一個範圍中既作為已捨棄的變數又作為函式速記。 @@ -1342,6 +1337,11 @@ 使用具有 'NoEagerConstraintApplicationAttribute' 的方法需要 /langversion:6.0 或更新版本 + + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + This active pattern returns {0} value(s), but the usage here matches {1} return value(s). + + No static abstract member was found that corresponds to this override 找不到對應到這個覆寫的靜態抽象成員 From 03bd55addf5c71b7a7fc391a459d95961e928137 Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Tue, 23 Apr 2024 23:04:13 +0800 Subject: [PATCH 15/22] split the error to four --- src/Compiler/Checking/CheckExpressions.fs | 22 ++++++++++------- src/Compiler/FSComp.txt | 7 +++--- src/Compiler/xlf/FSComp.txt.cs.xlf | 30 +++++++++++++++-------- src/Compiler/xlf/FSComp.txt.de.xlf | 30 +++++++++++++++-------- src/Compiler/xlf/FSComp.txt.es.xlf | 30 +++++++++++++++-------- src/Compiler/xlf/FSComp.txt.fr.xlf | 30 +++++++++++++++-------- src/Compiler/xlf/FSComp.txt.it.xlf | 30 +++++++++++++++-------- src/Compiler/xlf/FSComp.txt.ja.xlf | 30 +++++++++++++++-------- src/Compiler/xlf/FSComp.txt.ko.xlf | 30 +++++++++++++++-------- src/Compiler/xlf/FSComp.txt.pl.xlf | 30 +++++++++++++++-------- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 30 +++++++++++++++-------- src/Compiler/xlf/FSComp.txt.ru.xlf | 30 +++++++++++++++-------- src/Compiler/xlf/FSComp.txt.tr.xlf | 30 +++++++++++++++-------- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 30 +++++++++++++++-------- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 30 +++++++++++++++-------- 15 files changed, 277 insertions(+), 142 deletions(-) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index cee08858b43..74ade75dab2 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -5138,9 +5138,15 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags let dtys, retTy = stripFunTy g vExprTy let paramCount = if dtys.Length = 0 then 0 else dtys.Length - 1 - let showErrMsg returnCount actualParamCount actualReturnCount = - if paramCount = 0 then error(Error(FSComp.SR.tcNoParameterActivePatternArgumentCountNotMatch(returnCount, actualParamCount + actualReturnCount), m)) - else error(Error(FSComp.SR.tcParameterizedActivePatternArgumentCountNotMatch(paramCount, returnCount, actualParamCount, actualReturnCount), m)) + let showErrMsg returnCount = + let caseName = apinfo.ActiveTags[idx] + let msg = + match paramCount, returnCount with + | 0, 0 -> FSComp.SR.tcActivePatternArgsCountNotMatchNoArgsNoPat(caseName, caseName) + | 0, _ -> FSComp.SR.tcActivePatternArgsCountNotMatchOnlyPat(caseName) + | _, 0 -> FSComp.SR.tcActivePatternArgsCountNotMatchArgs(paramCount, caseName) + | _, _ -> FSComp.SR.tcActivePatternArgsCountNotMatchArgsAndPat(paramCount, caseName) + error(Error(msg, m)) // partial active pattern (returning bool) doesn't have output arg if (not apinfo.IsTotal && isBoolTy g retTy) then @@ -5148,7 +5154,7 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags if paramCount = (args: _ list).Length then args, SynPat.Const(SynConst.Unit, m) else - showErrMsg 0 args.Length 0 + showErrMsg 0 // for single case active pattern, if not all parameter provided, output will be a function // that takes the remaining parameter as input @@ -5167,17 +5173,15 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags if canOmit caseRetTy then args, SynPat.Const(SynConst.Unit, m) else - showErrMsg 1 args.Length 0 + showErrMsg 1 // active pattern (returning unknown things) can not omit output arg elif IsNotSolved vExprTy then List.frontAndBack args // active pattern (returning 'a or 'Boxed<'a>) can not omit output arg - elif dtys.Length > args.Length then - showErrMsg 1 args.Length 0 - elif dtys.Length < args.Length then - showErrMsg 1 (args.Length - 1) 1 + elif dtys.Length <> args.Length then + showErrMsg 1 else List.frontAndBack args diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 84ac74b2d9f..5cbeb406e0a 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1748,6 +1748,7 @@ featureReuseSameFieldsInStructUnions,"Share underlying fields in a [] di 3865,parsOnlySimplePatternsAreAllowedInConstructors,"Only simple patterns are allowed in primary constructors" 3866,chkStaticAbstractInterfaceMembers,"A static abstract non-virtual interface member should only be called via type parameter (for example: 'T.%s)." 3867,chkStaticAbstractMembersOnClasses,"Classes cannot contain static abstract members." -3868,tcParameterizedActivePatternArgumentCountNotMatch,"This active pattern requires %d parameter(s) and returns %d value(s), but the usage here matches %d argument(s) and %d return value(s)." -3869,tcNoParameterActivePatternArgumentCountNotMatch,"This active pattern returns %d value(s), but the usage here matches %d return value(s)." - +3868,tcActivePatternArgsCountNotMatchNoArgsNoPat,"This active pattern does not expect any arguments, i.e., it should be used like '%s' instead of '%s x'." +3868,tcActivePatternArgsCountNotMatchOnlyPat,"This active pattern expects exactly one pattern argument, e.g., '%s x'." +3868,tcActivePatternArgsCountNotMatchArgs,"This active pattern expects %d expression argument(s), e.g., '%s e1...'." +3868,tcActivePatternArgsCountNotMatchArgsAndPat,"This active pattern expects %d expression argument(s) and a pattern argument, e.g., '%s e1... pat'." diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 58e49c5eb3a..132b8246c32 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -1122,6 +1122,26 @@ (Navržený název) + + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + + + + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + + + + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + + + + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. Význam _ je tady nejednoznačný. Nelze ho použít pro proměnnou typu discard a zkratku funkce ve stejném oboru. @@ -1347,11 +1367,6 @@ Použití metod s atributem NoEagerConstraintApplicationAttribute vyžaduje /langversion:6.0 nebo novější. - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - No static abstract member was found that corresponds to this override Nenašla se žádný statický abstraktní člen, který by odpovídal tomuto přepsání. @@ -1397,11 +1412,6 @@ Toto přepsání přebírá řazenou kolekci členů místo více argumentů. Zkuste do definice metody přidat další vrstvu závorek, např. member _. Foo((x, y)) nebo odeberte závorky v deklaraci abstraktní metody (např. 'abstract member Foo: 'a * 'b -> 'c'). - - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - - The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. Syntaxe (expr1)[expr2] je při použití jako argument nejednoznačná. Více informací: https://aka.ms/fsharp-index-notation. Pokud plánujete indexování nebo vytváření řezů, musíte použít (expr1).[expr2] na pozici argumentu. Pokud voláte funkci s vícenásobnými curryfikovanými argumenty, přidejte mezi ně mezeru, třeba someFunction (expr1) [expr2]. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 1a06a768abb..81259928ed9 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -1122,6 +1122,26 @@ (Empfohlener Name) + + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + + + + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + + + + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + + + + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. Die Bedeutung von "_" ist hier mehrdeutig. Dieses Zeichen kann nicht in demselben Bereich für eine verworfene Variable und ein Funktionskürzel verwendet werden. @@ -1347,11 +1367,6 @@ Die Verwendung von Methoden mit "NoEagerConstraintApplicationAttribute" erfordert /langversion:6.0 oder höher. - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - No static abstract member was found that corresponds to this override Es wurde kein abstrakter Member gefunden, der dieser Überschreibung entspricht. @@ -1397,11 +1412,6 @@ Diese Außerkraftsetzung akzeptiert ein Tupel anstelle mehrerer Argumente. Fügen Sie der Methodendefinition eine zusätzliche Ebene von Klammern hinzu (z. B. "member _. Foo((x, y))"), oder entfernen Sie Klammern in der abstrakten Methodendeklaration (z. B. "abstract member Foo: 'a * 'b -> 'c"). - - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - - The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. Die Syntax "(expr1)[expr2]" ist mehrdeutig, wenn sie als Argument verwendet wird. Siehe https://aka.ms/fsharp-index-notation. Wenn Sie indizieren oder aufteilen möchten, müssen Sie "(expr1).[expr2]' in Argumentposition verwenden. Wenn Sie eine Funktion mit mehreren geschweiften Argumenten aufrufen, fügen Sie ein Leerzeichen dazwischen hinzu, z. B. "someFunction (expr1) [expr2]". diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index d4303557520..f1beea8a300 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -1122,6 +1122,26 @@ (Nombre sugerido) + + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + + + + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + + + + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + + + + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. El significado de _ es ambiguo aquí. No se puede usar para una variable descartada y una función abreviada en el mismo ámbito. @@ -1347,11 +1367,6 @@ El uso de métodos con "NoEagerConstraintApplicationAttribute" requiere /langversion:6.0 o posteriores - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - No static abstract member was found that corresponds to this override No se encontró ningún miembro abstracto estático que corresponda a esta invalidación. @@ -1397,11 +1412,6 @@ Esta invalidación toma una tupla en lugar de varios argumentos. Intente agregar una capa adicional de paréntesis en la definición del método (por ejemplo, “member _. Foo((x, y))”) o quitar paréntesis en la declaración de método abstracto (por ejemplo, “abstract member Foo: “a * “b -> “c”). - - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - - The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. La sintaxis "(expr1)[expr2]" es ambigua cuando se usa como argumento. Vea https://aka.ms/fsharp-index-notation. Si piensa indexar o segmentar, debe usar "(expr1).[expr2]" en la posición del argumento. Si se llama a una función con varios argumentos currificados, se agregará un espacio entre ellos, por ejemplo, "unaFunción (expr1) [expr2]". diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 0b198dca723..c525f5828d1 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -1122,6 +1122,26 @@ (Nom suggéré) + + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + + + + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + + + + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + + + + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. La signification de _ est ici ambiguë. Il ne peut pas être utilisé pour une variable ignorée et un raccourci de fonction dans la même portée. @@ -1347,11 +1367,6 @@ L’utilisation de méthodes avec « NoEagerConstraintApplicationAttribute » requiert/langversion:6.0 ou ultérieur - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - No static abstract member was found that corresponds to this override Désolé, nous n’avons pas pu trouver un membre abstrait statique qui corresponde à cette substitution @@ -1397,11 +1412,6 @@ Ce remplacement prend un tuple au lieu de plusieurs arguments. Essayez d'ajouter une couche supplémentaire de parenthèses à la définition de la méthode (par exemple 'member _.Foo((x, y))'), ou supprimez les parenthèses au niveau de la déclaration de la méthode abstraite (par exemple 'abstract member Foo: 'a * 'b -> 'c'). - - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - - The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. La syntaxe « (expr1)[expr2] » est ambiguë lorsqu’elle est utilisée comme argument. Voir https://aka.ms/fsharp-index-notation. Si vous avez l’intention d’indexer ou de découper, vous devez utiliser « (expr1).[expr2] » en position d’argument. Si vous appelez une fonction avec plusieurs arguments codés, ajoutez un espace entre eux, par exemple « someFunction (expr1) [expr2] ». diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 5484e2d491e..96e8d36dfc3 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -1122,6 +1122,26 @@ (Nome consigliato) + + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + + + + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + + + + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + + + + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. Il significato di _ è ambiguo in questo contesto. Non può essere utilizzato per una variabile eliminata e una sintassi abbreviata di funzione nello stesso ambito. @@ -1347,11 +1367,6 @@ L'utilizzo di metodi con 'NoEagerConstraintApplicationAttribute' richiede /langversion: 6.0 o versione successiva - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - No static abstract member was found that corresponds to this override Nessun membro astratto statico trovato corrispondente all'override @@ -1397,11 +1412,6 @@ Questa sostituzione accetta una tupla anziché più argomenti. Prova ad aggiungere un ulteriore livello di parentesi alla definizione del metodo (ad esempio 'member _.Foo((x, y))') o rimuovi le parentesi nella dichiarazione del metodo astratto (ad esempio, 'abstract member Foo: 'a * 'b -> 'c'). - - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - - The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. La sintassi '(expr1)[expr2]' è ambigua se usata come argomento. Vedere https://aka.ms/fsharp-index-notation. Se si intende eseguire l'indicizzazione o il sezionamento, è necessario usare '(expr1).[expr2]' nella posizione dell'argomento. Se si chiama una funzione con più argomenti sottoposti a corsi, aggiungere uno spazio tra di essi, ad esempio 'someFunction (expr1) [expr2]'. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index cfa71047435..4d8fb592fa0 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -1122,6 +1122,26 @@ (推奨される名前) + + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + + + + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + + + + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + + + + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. ここでは _ の意味はあいまいです。破棄された変数と、同じスコープ内の関数の短縮形には使用できません。 @@ -1347,11 +1367,6 @@ 'NoEagerConstraintApplicationAttribute' を指定してメソッドを使用するには、/langversion:6.0 以降が必要です - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - No static abstract member was found that corresponds to this override このオーバーライドに対応する静的抽象メンバーが見つかりませんでした @@ -1397,11 +1412,6 @@ このオーバーライドは、複数の引数ではなくタプルを受け取ります。メソッド定義にかっこのレイヤーを追加してみるか (例: 'member _.Foo((x, y))')、または抽象メソッド宣言でかっこを削除します (例: 'abstract member Foo: 'a * 'b -> 'c')。 - - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - - The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. 構文 '(expr1)[expr2]' は引数として使用されている場合、あいまいです。https://aka.ms/fsharp-index-notation を参照してください。インデックス作成またはスライスを行う場合は、'(expr1).[expr2]' を引数の位置に使用する必要があります。複数のカリー化された引数を持つ関数を呼び出す場合は、'someFunction (expr1) [expr2]' のように間にスペースを追加します。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 2629212a168..b65ddc7e27e 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -1122,6 +1122,26 @@ (제안된 이름) + + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + + + + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + + + + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + + + + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. 여기서 _의 의미가 모호합니다. 삭제된 변수와 동일한 범위의 함수 줄임에는 사용할 수 없습니다. @@ -1347,11 +1367,6 @@ 'NoEagerConstraintApplicationAttribute'와 함께 메서드를 사용하려면 /langversion:6.0 이상이 필요합니다. - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - No static abstract member was found that corresponds to this override 이 재정의에 해당하는 정적 추상 멤버를 찾을 수 없습니다. @@ -1397,11 +1412,6 @@ 이 재정의는 여러 인수 대신 튜플을 사용합니다. 메서드 정의에 괄호 계층을 더 추가하거나(예: 'member _.Foo((x, y))') 추상 메서드 선언에서 괄호를 제거하세요(예: 'abstract member Foo: 'a * 'b -> 'c'). - - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - - The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. '(expr1)[expr2]' 구문은 인수로 사용될 때 모호합니다. https://aka.ms/fsharp-index-notation을 참조하세요. 인덱싱이나 슬라이싱을 하려면 인수 위치에 '(expr1).[expr2]'를 사용해야 합니다. 여러 개의 커리된 인수로 함수를 호출하는 경우 그 사이에 공백을 추가하세요(예: 'someFunction (expr1) [expr2]'). diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index b5b3cd730c9..eefa92895c8 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -1122,6 +1122,26 @@ (Sugerowana nazwa) + + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + + + + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + + + + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + + + + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. Znaczenie elementu _ jest tutaj niejednoznaczne. Nie można go użyć dla odrzuconej zmiennej i skrótu funkcji w tym samym zakresie. @@ -1347,11 +1367,6 @@ Używanie metod z atrybutem "NoEagerConstraintApplicationAttribute" wymaga parametru /langversion:6.0 lub nowszego - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - No static abstract member was found that corresponds to this override Nie odnaleziono żadnego statycznego abstrakcyjnego elementu członkowskiego odpowiadającego temu przesłonięciu @@ -1397,11 +1412,6 @@ To zastąpienie przyjmuje krotki zamiast wielu argumentów. Spróbuj dodać dodatkową warstwę nawiasów w definicji metody (np. „member _. Foo((x, y))”) lub usuń nawiasy w deklaracji metody abstrakcyjnej (np. „abstract member Foo: „a * ”b -> „c”). - - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - - The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. Składnia wyrażenia „(expr1)[expr2]” jest niejednoznaczna, gdy jest używana jako argument. Zobacz https://aka.ms/fsharp-index-notation. Jeśli zamierzasz indeksować lub fragmentować, to w pozycji argumentu musi być użyte wyrażenie „(expr1).[expr2]”. Jeśli wywołujesz funkcję z wieloma argumentami typu curried, dodaj spację między nimi, np. „someFunction (expr1) [expr2]”. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 0b09fcf8069..088facd7613 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -1122,6 +1122,26 @@ (Nome sugerido) + + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + + + + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + + + + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + + + + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. O significado de _ é ambíguo aqui. Ele não pode ser usado para uma variável descartada e uma abreviação de função no mesmo escopo. @@ -1347,11 +1367,6 @@ Usar métodos com 'NoEagerConstraintApplicationAttribute' requer /langversion:6.0 ou posterior - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - No static abstract member was found that corresponds to this override Nenhum membro abstrato estático encontrado que corresponda a esta substituição @@ -1397,11 +1412,6 @@ Essa substituição usa uma tupla em vez de vários argumentos. Tente adicionar uma camada adicional de parênteses na definição do método (por exemplo, "member _. Foo((x, y))") ou remova os parênteses na declaração de método abstrato (por exemplo, "membro abstrato Foo: 'a * 'b -> 'c"). - - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - - The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. A sintaxe '[expr1][expr2]' é ambígua quando usada como um argumento. Consulte https://aka.ms/fsharp-index-notation. Se você pretende indexar ou colocar em fatias, deve usar '(expr1).[expr2]' na posição do argumento. Se chamar uma função com vários argumentos na forma curried, adicione um espaço entre eles, por exemplo, 'someFunction [expr1] [expr2]'. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 31597a8818c..5a80ceb1ed2 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -1122,6 +1122,26 @@ (предложенное имя) + + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + + + + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + + + + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + + + + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. Неоднозначное значение символа _ здесь. Его нельзя использовать для пустой переменной и сокращенной функции в одной области. @@ -1347,11 +1367,6 @@ Для использования методов с "NoEagerConstraintApplicationAttribute" требуется /langversion:6.0 или более поздняя версия - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - No static abstract member was found that corresponds to this override Не найден статический абстрактный элемент, соответствующий этому переопределению. @@ -1397,11 +1412,6 @@ Это переопределение принимает кортеж вместо нескольких аргументов. Попробуйте добавить дополнительный слой круглых скобок в определении метода (например, "member _.Foo((x, y))") или удалить круглые скобки в объявлении абстрактного метода (например, "abstract member Foo: "a * "b -> "c"). - - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - - The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. Синтаксис "(expr1)[expr2]" неоднозначен при использовании в качестве аргумента. См. https://aka.ms/fsharp-index-notation. Если вы намереваетесь индексировать или разрезать, необходимо использовать "(expr1).[expr2]" в позиции аргумента. При вызове функции с несколькими каррированными аргументами добавьте пробел между ними, например "someFunction (expr1) [expr2]". diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 6cf1e2ebd1b..2e369a41152 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -1122,6 +1122,26 @@ (Önerilen ad) + + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + + + + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + + + + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + + + + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. _ öğesinin anlamı burada belirsiz. Aynı kapsamda, atılan bir değişken ve işlev kısaltması için kullanılamaz. @@ -1347,11 +1367,6 @@ 'NoEagerConstraintApplicationAttribute' içeren yöntemlerin kullanılması /langversion:6.0 veya üstünü gerektiriyor - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - No static abstract member was found that corresponds to this override Bu geçersiz kılmaya karşılık gelen hiçbir statik soyut üye bulunamadı @@ -1397,11 +1412,6 @@ Bu geçersiz kılma, birden çok bağımsız değişken yerine bir tanımlama grubu alır. Metot tanımına ek bir parantez katmanı (ör. 'member _. Foo((x, y)')) eklemeyi deneyin veya soyut yöntem bildirimindeki parantezleri kaldırın (ör. 'abstract member Foo: 'a * 'b -> 'c'). - - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - - The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. Söz dizimi “(expr1)[expr2]” bağımsız değişken olarak kullanıldığında belirsizdir. https://aka.ms/fsharp-index-notation'a bakın. Dizin oluşturmayı veya dilimlemeyi düşünüyorsanız, bağımsız değişken konumunda “(expr1).[expr2]” kullanmalısınız. Birden çok curry bağımsız değişkenli bir işlev çağırıyorsanız, aralarına bir boşluk ekleyin, örn. “someFunction (expr1) [expr2]”. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 8146658fa7b..43cf3f3146b 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -1122,6 +1122,26 @@ (建议名称) + + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + + + + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + + + + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + + + + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. 此处的 _ 含义不明确。它不能用于同一范围内的已放弃变量和函数速记。 @@ -1347,11 +1367,6 @@ 将方法与 “NoEagerConstraintApplicationAttribute” 配合使用需要 /langversion:6.0 或更高版本 - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - No static abstract member was found that corresponds to this override 找不到与此替代对应的静态抽象成员 @@ -1397,11 +1412,6 @@ 此重写采用元组而不是多个参数。请尝试在方法定义中添加额外的括号层(例如 'member _.Foo((x, y))'),或在抽象方法声明中删除括号 (例如 'abstract member Foo: 'a * 'b -> 'c')。 - - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - - The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. 语法“(expr1)[expr2]”用作参数时不明确。请参阅 https://aka.ms/fsharp-index-notation。如果要索引或切片,则必须在参数位置使用“(expr1)[expr2]”。如果使用多个扩充参数调用函数,请在它们之间添加空格,例如“someFunction (expr1)[expr2]”。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index ea9ddc4f6f4..8cb49b76b97 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -1122,6 +1122,26 @@ (建議的名稱) + + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + + + + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + + + + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + This active pattern does not expect any arguments, i.e., it should be used like '{0}' instead of '{1} x'. + + + + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} x'. + + The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope. 此處的 _ 意義不明確。它不能在同一個範圍中既作為已捨棄的變數又作為函式速記。 @@ -1347,11 +1367,6 @@ 使用具有 'NoEagerConstraintApplicationAttribute' 的方法需要 /langversion:6.0 或更新版本 - - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - This active pattern returns {0} value(s), but the usage here matches {1} return value(s). - - No static abstract member was found that corresponds to this override 找不到對應到這個覆寫的靜態抽象成員 @@ -1397,11 +1412,6 @@ 此覆寫接受一個元組,而不是多個引數。請嘗試在方法定義中新增額外一層括弧 (例如 'member _.Foo((x, y))'),或在抽象方法宣告中移除括弧 (例如 'abstract member Foo: 'a * 'b -> 'c')。 - - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - This active pattern requires {0} parameter(s) and returns {1} value(s), but the usage here matches {2} argument(s) and {3} return value(s). - - The syntax '(expr1)[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use '(expr1).[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction (expr1) [expr2]'. 語法 '(expr1)[expr2]' 用作引數時不明確。請參閱 https://aka.ms/fsharp-index-notation。如果您要編製索引或切割,則必須在引數位置使用 '(expr1).[expr2]'。如果要呼叫具有多個調用引數的函式,請在它們之間新增空格,例如 'someFunction (expr1) [expr2]'。 From c93bb368cf0f88c8a5068025494845bf9823197f Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Tue, 23 Apr 2024 23:59:15 +0800 Subject: [PATCH 16/22] fix test --- docs/release-notes/.FSharp.Compiler.Service/8.0.300.md | 1 - docs/release-notes/.FSharp.Compiler.Service/8.0.400.md | 4 ++++ ...turningAndReturnTypeDirectedPartialActivePatternTests.fs | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md index d05eaa23c59..57bc1578db3 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md @@ -58,4 +58,3 @@ * Optimize some interpolated strings by lowering to string concatenation. ([PR #16556](https://github.com/dotnet/fsharp/pull/16556)) * Speed up `for x in xs -> …` in list & array comprehensions in certain scenarios. ([PR #16948](https://github.com/dotnet/fsharp/pull/16948)) * Integral range optimizations. ([PR #16650](https://github.com/dotnet/fsharp/pull/16650), [PR #16832](https://github.com/dotnet/fsharp/pull/16832), [PR #16947](https://github.com/dotnet/fsharp/pull/16947)) -* Add error tcActivePatternArgumentCountNotMatch ([PR #16846](https://github.com/dotnet/fsharp/pull/16846)) diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md index 16ead61175e..84b8c9ef275 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md @@ -9,3 +9,7 @@ * Fix bug in optimization of for-loops over integral ranges with steps and units of measure. ([Issue #17025](https://github.com/dotnet/fsharp/issues/17025), [PR #17040](https://github.com/dotnet/fsharp/pull/17040), [PR #17048](https://github.com/dotnet/fsharp/pull/17048)) * Fix calling an overridden virtual static method via the interface ([PR #17013](https://github.com/dotnet/fsharp/pull/17013)) * Fix state machines compilation, when big decision trees are involved, by removing code split when resumable code is detected ([PR #17076](https://github.com/dotnet/fsharp/pull/17076)) + +### Changed + +* Improve error of Active Pattern case Argument Count Not Match ([PR #16846](https://github.com/dotnet/fsharp/pull/16846)) diff --git a/tests/FSharp.Compiler.ComponentTests/Language/BooleanReturningAndReturnTypeDirectedPartialActivePatternTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/BooleanReturningAndReturnTypeDirectedPartialActivePatternTests.fs index a8260ceed12..c8ba6fba856 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/BooleanReturningAndReturnTypeDirectedPartialActivePatternTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/BooleanReturningAndReturnTypeDirectedPartialActivePatternTests.fs @@ -94,9 +94,9 @@ match "A" with |> typecheck |> shouldFail |> withDiagnostics [ - (Error 3867, Line 5, Col 3, Line 5, Col 13, "This active pattern returns 0 value(s), but the usage here matches 1 return value(s).") - (Error 3867, Line 9, Col 3, Line 9, Col 13, "This active pattern returns 0 value(s), but the usage here matches 1 return value(s).") + (Error 3868, Line 5, Col 3, Line 5, Col 13, "This active pattern does not expect any arguments, i.e., it should be used like 'IsA' instead of 'IsA x'.") + (Error 3868, Line 9, Col 3, Line 9, Col 13, "This active pattern does not expect any arguments, i.e., it should be used like 'IsA' instead of 'IsA x'.") (Error 0039, Line 9, Col 17, Line 9, Col 23, "The value or constructor 'result' is not defined. Maybe you want one of the following: Result") - (Error 3867, Line 13, Col 3, Line 13, Col 30, "This active pattern returns 0 value(s), but the usage here matches 1 return value(s).") + (Error 3868, Line 13, Col 3, Line 13, Col 30, "This active pattern does not expect any arguments, i.e., it should be used like 'IsA' instead of 'IsA x'.") ] From 1d67d54ddbb087f1e2570fe33d4c5c135c97e86c Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Fri, 26 Apr 2024 15:32:58 +0800 Subject: [PATCH 17/22] improve msg --- src/Compiler/Checking/CheckExpressions.fs | 13 ++++++- src/Compiler/FSComp.txt | 6 +-- src/Compiler/xlf/FSComp.txt.cs.xlf | 12 +++--- src/Compiler/xlf/FSComp.txt.de.xlf | 12 +++--- src/Compiler/xlf/FSComp.txt.es.xlf | 12 +++--- src/Compiler/xlf/FSComp.txt.fr.xlf | 12 +++--- src/Compiler/xlf/FSComp.txt.it.xlf | 12 +++--- src/Compiler/xlf/FSComp.txt.ja.xlf | 12 +++--- src/Compiler/xlf/FSComp.txt.ko.xlf | 12 +++--- src/Compiler/xlf/FSComp.txt.pl.xlf | 12 +++--- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 12 +++--- src/Compiler/xlf/FSComp.txt.ru.xlf | 12 +++--- src/Compiler/xlf/FSComp.txt.tr.xlf | 12 +++--- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 12 +++--- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 12 +++--- .../ActivePatternArgCountMismatchTest.fs | 39 +++++++++++++++++++ .../FSharp.Compiler.ComponentTests.fsproj | 2 + 17 files changed, 133 insertions(+), 83 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/ErrorMessages/ActivePatternArgCountMismatchTest.fs diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index f854efee091..5a613046afb 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -5134,13 +5134,22 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags let paramCount = if dtys.Length = 0 then 0 else dtys.Length - 1 let showErrMsg returnCount = + let fmtExprArgs paramCount = + let rec loop i (sb: Text.StringBuilder) = + let cutoff = 10 + if i > paramCount then sb.ToString() + elif i > cutoff then sb.Append("...").ToString() + else loop (i + 1) (sb.Append(" e").Append i) + + loop 1 (Text.StringBuilder()) + let caseName = apinfo.ActiveTags[idx] let msg = match paramCount, returnCount with | 0, 0 -> FSComp.SR.tcActivePatternArgsCountNotMatchNoArgsNoPat(caseName, caseName) | 0, _ -> FSComp.SR.tcActivePatternArgsCountNotMatchOnlyPat(caseName) - | _, 0 -> FSComp.SR.tcActivePatternArgsCountNotMatchArgs(paramCount, caseName) - | _, _ -> FSComp.SR.tcActivePatternArgsCountNotMatchArgsAndPat(paramCount, caseName) + | _, 0 -> FSComp.SR.tcActivePatternArgsCountNotMatchArgs(paramCount, caseName, fmtExprArgs paramCount) + | _, _ -> FSComp.SR.tcActivePatternArgsCountNotMatchArgsAndPat(paramCount, caseName, fmtExprArgs paramCount) error(Error(msg, m)) // partial active pattern (returning bool) doesn't have output arg diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 5cbeb406e0a..25047f08e39 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1749,6 +1749,6 @@ featureReuseSameFieldsInStructUnions,"Share underlying fields in a [] di 3866,chkStaticAbstractInterfaceMembers,"A static abstract non-virtual interface member should only be called via type parameter (for example: 'T.%s)." 3867,chkStaticAbstractMembersOnClasses,"Classes cannot contain static abstract members." 3868,tcActivePatternArgsCountNotMatchNoArgsNoPat,"This active pattern does not expect any arguments, i.e., it should be used like '%s' instead of '%s x'." -3868,tcActivePatternArgsCountNotMatchOnlyPat,"This active pattern expects exactly one pattern argument, e.g., '%s x'." -3868,tcActivePatternArgsCountNotMatchArgs,"This active pattern expects %d expression argument(s), e.g., '%s e1...'." -3868,tcActivePatternArgsCountNotMatchArgsAndPat,"This active pattern expects %d expression argument(s) and a pattern argument, e.g., '%s e1... pat'." +3868,tcActivePatternArgsCountNotMatchOnlyPat,"This active pattern expects exactly one pattern argument, e.g., '%s pat'." +3868,tcActivePatternArgsCountNotMatchArgs,"This active pattern expects %d expression argument(s), e.g., '%s%s'." +3868,tcActivePatternArgsCountNotMatchArgsAndPat,"This active pattern expects %d expression argument(s) and a pattern argument, e.g., '%s%s pat'." diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 132b8246c32..a4e8e281866 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -1123,13 +1123,13 @@ - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. @@ -1138,8 +1138,8 @@ - This active pattern expects exactly one pattern argument, e.g., '{0} x'. - This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 81259928ed9..f920991d5f4 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -1123,13 +1123,13 @@ - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. @@ -1138,8 +1138,8 @@ - This active pattern expects exactly one pattern argument, e.g., '{0} x'. - This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index f1beea8a300..f6054605ffa 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -1123,13 +1123,13 @@ - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. @@ -1138,8 +1138,8 @@ - This active pattern expects exactly one pattern argument, e.g., '{0} x'. - This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index c525f5828d1..5e9349ac3ae 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -1123,13 +1123,13 @@ - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. @@ -1138,8 +1138,8 @@ - This active pattern expects exactly one pattern argument, e.g., '{0} x'. - This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 96e8d36dfc3..b936cdc3642 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -1123,13 +1123,13 @@ - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. @@ -1138,8 +1138,8 @@ - This active pattern expects exactly one pattern argument, e.g., '{0} x'. - This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 4d8fb592fa0..add97ebcbee 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -1123,13 +1123,13 @@ - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. @@ -1138,8 +1138,8 @@ - This active pattern expects exactly one pattern argument, e.g., '{0} x'. - This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index b65ddc7e27e..005109642a3 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -1123,13 +1123,13 @@ - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. @@ -1138,8 +1138,8 @@ - This active pattern expects exactly one pattern argument, e.g., '{0} x'. - This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index eefa92895c8..b11a525807f 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -1123,13 +1123,13 @@ - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. @@ -1138,8 +1138,8 @@ - This active pattern expects exactly one pattern argument, e.g., '{0} x'. - This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 088facd7613..78b23fc160d 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -1123,13 +1123,13 @@ - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. @@ -1138,8 +1138,8 @@ - This active pattern expects exactly one pattern argument, e.g., '{0} x'. - This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 5a80ceb1ed2..670b03ce32a 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -1123,13 +1123,13 @@ - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. @@ -1138,8 +1138,8 @@ - This active pattern expects exactly one pattern argument, e.g., '{0} x'. - This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 2e369a41152..e0552438c26 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -1123,13 +1123,13 @@ - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. @@ -1138,8 +1138,8 @@ - This active pattern expects exactly one pattern argument, e.g., '{0} x'. - This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 43cf3f3146b..f53a45b0200 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -1123,13 +1123,13 @@ - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. @@ -1138,8 +1138,8 @@ - This active pattern expects exactly one pattern argument, e.g., '{0} x'. - This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 8cb49b76b97..a80e8852c30 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -1123,13 +1123,13 @@ - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. - This active pattern expects {0} expression argument(s), e.g., '{1} e1...'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. + This active pattern expects {0} expression argument(s), e.g., '{1}{2}'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. - This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1} e1... pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. + This active pattern expects {0} expression argument(s) and a pattern argument, e.g., '{1}{2} pat'. @@ -1138,8 +1138,8 @@ - This active pattern expects exactly one pattern argument, e.g., '{0} x'. - This active pattern expects exactly one pattern argument, e.g., '{0} x'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. + This active pattern expects exactly one pattern argument, e.g., '{0} pat'. diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ActivePatternArgCountMismatchTest.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ActivePatternArgCountMismatchTest.fs new file mode 100644 index 00000000000..d4c4f2d1668 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ActivePatternArgCountMismatchTest.fs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace ErrorMessages + +open Xunit +open FSharp.Test.Compiler + +module ``Active Pattern argument count mismatch test`` = + + [] + let ``test``() = + FSharp """ +let (|IsEven|_|) x = x % 2 = 0 +match 1 with +| IsEven xxx -> () +| _ -> printfn "Odd!" + +let (|Ignore|) x = () +match 1 with +| Ignore () () -> printfn "Ignored!" +| _ -> () + +let (|Equals|_|) z y x = x = y +match 1 with +| Equals "" 2 xxx -> () +| _ -> printfn "Not Equal" + +let (|A|) a b c d = d +match 1 with +| A -> () +| _ -> () + """ |> typecheck + |> shouldSucceed + |> withDiagnostics [ + (Error 3868, Line 4, Col 3, Line 4, Col 13, "This active pattern does not expect any arguments, i.e., it should be used like 'IsEven' instead of 'IsEven x'.") + (Error 3868, Line 9, Col 3, Line 9, Col 15, "This active pattern expects exactly one pattern argument, e.g., 'Ignore pat'.") + (Error 3868, Line 14, Col 3, Line 14, Col 18, "This active pattern expects 2 expression argument(s), e.g., 'Equals e1 e2'.") + (Error 3868, Line 19, Col 3, Line 19, Col 4, "This active pattern expects 3 expression argument(s) and a pattern argument, e.g., 'A e1 e2 e3 pat'.") + ] diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 6924b94f448..fec09aa52d9 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -208,6 +208,7 @@ + @@ -331,6 +332,7 @@ + From bb550f49b9bcf21e3ff541de93de0ed22c40461a Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Fri, 26 Apr 2024 17:27:29 +0800 Subject: [PATCH 18/22] fix test --- .../ErrorMessages/ActivePatternArgCountMismatchTest.fs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ActivePatternArgCountMismatchTest.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ActivePatternArgCountMismatchTest.fs index d4c4f2d1668..96f1c8baaa7 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ActivePatternArgCountMismatchTest.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ActivePatternArgCountMismatchTest.fs @@ -29,7 +29,8 @@ let (|A|) a b c d = d match 1 with | A -> () | _ -> () - """ |> typecheck + """ |> withLangVersionPreview + |> typecheck |> shouldSucceed |> withDiagnostics [ (Error 3868, Line 4, Col 3, Line 4, Col 13, "This active pattern does not expect any arguments, i.e., it should be used like 'IsEven' instead of 'IsEven x'.") From 7c701928b5babe436560aa8c04511d63ad6ff10d Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Fri, 26 Apr 2024 18:35:14 +0800 Subject: [PATCH 19/22] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20ActivePatternArgCoun?= =?UTF-8?q?tMismatchTest.fs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ErrorMessages/ActivePatternArgCountMismatchTest.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ActivePatternArgCountMismatchTest.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ActivePatternArgCountMismatchTest.fs index 96f1c8baaa7..77fd98449b0 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ActivePatternArgCountMismatchTest.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ActivePatternArgCountMismatchTest.fs @@ -31,7 +31,7 @@ match 1 with | _ -> () """ |> withLangVersionPreview |> typecheck - |> shouldSucceed + |> shouldFail |> withDiagnostics [ (Error 3868, Line 4, Col 3, Line 4, Col 13, "This active pattern does not expect any arguments, i.e., it should be used like 'IsEven' instead of 'IsEven x'.") (Error 3868, Line 9, Col 3, Line 9, Col 15, "This active pattern expects exactly one pattern argument, e.g., 'Ignore pat'.") From f4b1938feab37d76ec777c5a7130d8a1bf2629a5 Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Tue, 30 Apr 2024 11:36:59 +0800 Subject: [PATCH 20/22] update to errorR --- src/Compiler/Checking/CheckExpressions.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index 5a613046afb..8ff99806709 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -5150,7 +5150,7 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags | 0, _ -> FSComp.SR.tcActivePatternArgsCountNotMatchOnlyPat(caseName) | _, 0 -> FSComp.SR.tcActivePatternArgsCountNotMatchArgs(paramCount, caseName, fmtExprArgs paramCount) | _, _ -> FSComp.SR.tcActivePatternArgsCountNotMatchArgsAndPat(paramCount, caseName, fmtExprArgs paramCount) - error(Error(msg, m)) + errorR(Error(msg, m)) // partial active pattern (returning bool) doesn't have output arg if (not apinfo.IsTotal && isBoolTy g retTy) then From d824f393ef3964771592976f5cbef0a6551f3550 Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Tue, 30 Apr 2024 12:29:07 +0800 Subject: [PATCH 21/22] revert errorR --- src/Compiler/Checking/CheckExpressions.fs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index ae8edeac5c1..aab03c39d03 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -5127,6 +5127,8 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags | None -> false | TType_var _ -> true | _ -> false + + // only cases which return unit or unresolved type (in AP definition) can omit output arg let canOmit retTy = isUnitTy g retTy || IsNotSolved retTy // This bit of type-directed analysis ensures that parameterized partial active patterns returning unit do not need to take an argument @@ -5150,12 +5152,12 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags | 0, _ -> FSComp.SR.tcActivePatternArgsCountNotMatchOnlyPat(caseName) | _, 0 -> FSComp.SR.tcActivePatternArgsCountNotMatchArgs(paramCount, caseName, fmtExprArgs paramCount) | _, _ -> FSComp.SR.tcActivePatternArgsCountNotMatchArgsAndPat(paramCount, caseName, fmtExprArgs paramCount) - errorR(Error(msg, m)) + error(Error(msg, m)) // partial active pattern (returning bool) doesn't have output arg if (not apinfo.IsTotal && isBoolTy g retTy) then checkLanguageFeatureError g.langVersion LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern m - if paramCount = (args: _ list).Length then + if paramCount = List.length args then args, SynPat.Const(SynConst.Unit, m) else showErrMsg 0 @@ -5165,7 +5167,7 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags elif apinfo.IsTotal && apinfo.ActiveTags.Length = 1 && dtys.Length >= args.Length && not args.IsEmpty then List.frontAndBack args - // active pattern (returning unit or 'Boxed) can omit output arg + // active pattern cases returning unit or unknown things (in AP definition) can omit output arg elif paramCount = args.Length then let caseRetTy = if isOptionTy g retTy then destOptionTy g retTy @@ -5173,17 +5175,13 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags elif isChoiceTy g retTy then destChoiceTy g retTy idx else retTy - // only 0 parameter single case active pattern can omit output arg + // only cases which return unit or unresolved type (in AP definition) can omit output arg if canOmit caseRetTy then args, SynPat.Const(SynConst.Unit, m) else showErrMsg 1 - // active pattern (returning unknown things) can not omit output arg - elif IsNotSolved vExprTy then - List.frontAndBack args - - // active pattern (returning 'a or 'Boxed<'a>) can not omit output arg + // args count should equal to AP function params count elif dtys.Length <> args.Length then showErrMsg 1 else From 09febb47252e1faeec841b1433b3bddb4ada7ff4 Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:28:50 +0800 Subject: [PATCH 22/22] fix --- src/Compiler/Checking/CheckExpressions.fs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index aab03c39d03..b5e2a39a4f7 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -5181,6 +5181,10 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags else showErrMsg 1 + // active pattern in function param (e.g. let f (|P|_|) = ...) + elif IsNotSolved vExprTy then + List.frontAndBack args + // args count should equal to AP function params count elif dtys.Length <> args.Length then showErrMsg 1