From e2683760f6d5055c8a00151b83483439fbdd5d8b Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 22 Sep 2022 18:49:23 +0200 Subject: [PATCH 01/12] Update FSComp to add a new error message --- src/Compiler/FSComp.txt | 1 + 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 +++++ 14 files changed, 66 insertions(+) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 64f0876b61d..612f883931d 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1653,3 +1653,4 @@ reprStateMachineInvalidForm,"The state machine has an unexpected form" 3536,tcUsingInterfaceWithStaticAbstractMethodAsType,"'%s' is normally used as a type constraint in generic code, e.g. \"'T when ISomeInterface<'T>\" or \"let f (x: #ISomeInterface<_>)\". See https://aka.ms/fsharp-iwsams for guidance. You can disable this warning by using '#nowarn \"3536\"' or '--nowarn:3536'." 3537,tcTraitHasMultipleSupportTypes,"The trait '%s' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance." 3545,tcMissingRequiredMembers,"The following required properties have to be initalized:%s" +3546,chkDuplicatedMethodParameter,"Duplicate parameter. The parameter '%s' has been used more that once in this method." diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 8a1853a380f..be3264fed5c 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -12,6 +12,11 @@ Soubor {0} má nerozpoznanou příponu. Zdrojové soubory musí mít příponu .fs, .fsi, .fsx nebo .fsscript. + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. Funkce {0} není v jazyce F# {1} dostupná. Použijte prosím jazyk verze {2} nebo vyšší. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index e96c8e1d3b2..193f0daa6a8 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -12,6 +12,11 @@ Die Dateierweiterung von „{0}“ wurde nicht erkannt. Quelldateien müssen die Erweiterung .fs, .fsi, .fsx oder .fsscript haben + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. Das Feature "{0}" ist in F# {1} nicht verfügbar. Verwenden Sie Sprachversion {2} oder höher. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 8c034062331..f784dff70e2 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -12,6 +12,11 @@ No se reconoce la extensión de archivo de '{0}'. Los archivos de código fuente deben tener las extensiones .fs, .fsi, .fsx o .fsscript + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. La característica "{0}" no está disponible en F# {1}. Use la versión {2} del lenguaje o una posterior. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index ab6345e8e0c..f962609b7fd 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -12,6 +12,11 @@ L'extension de fichier de '{0}' n'est pas reconnue. Les fichiers sources doivent avoir l'extension .fs, .fsi, .fsx, ou .fsscript. + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. La fonctionnalité '{0}' n'est pas disponible en F# {1}. Utilisez la version de langage {2} ou une version ultérieure. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 85a4a4cd333..be98b79735c 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -12,6 +12,11 @@ Estensione di file di '{0}' non riconosciuta. I file di origine devono avere estensione .fs, .fsi, .fsx or .fsscript + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. La funzionalità '{0}' non è disponibile in F# {1}. Usare la versione {2} o versioni successive del linguaggio. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 1a49a44350e..2405b257c5c 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -12,6 +12,11 @@ '{0}' のファイル拡張子は認識されません。ソース ファイルの拡張子は .fs、.fsi、.fsx、または .fsscript にする必要があります。 + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. 機能 '{0}' は F# {1} では使用できません。{2} 以上の言語バージョンをお使いください。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 1a4cb6964d8..327f7c45ba4 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -12,6 +12,11 @@ '{0}'의 파일 확장명을 인식할 수 없습니다. 원본 파일의 확장명은 .fs, .fsi, .fsx 또는 .fsscript여야 합니다. + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. '{0}' 기능은 F# {1}에서 사용할 수 없습니다. {2} 이상의 언어 버전을 사용하세요. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 1cc8dfb88f1..575edbee810 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -12,6 +12,11 @@ Rozszerzenie pliku "{0}" nie zostało rozpoznane. Pliki źródłowe muszą mieć rozszerzenie .fs, .fsi, .fsx lub .fsscript + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. Funkcja „{0}” nie jest dostępna w języku F# {1}. Użyj języka w wersji {2} lub nowszej. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 1c898a6234e..77204958a5a 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -12,6 +12,11 @@ A extensão do arquivo de '{0}' não foi reconhecida. Os arquivos de origem devem ter a extensão .fs, .fsi, .fsx or .fsscript + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. O recurso '{0}' não está disponível no F# {1}. Use a versão da linguagem {2} ou superior. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index b9094d89e3f..cbe410f57ae 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -12,6 +12,11 @@ Расширение файла "{0}" не распознано. Исходные файлы должны иметь расширения FS, FSI, FSX или FSSCRIPT + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. Компонент "{0}" недоступен в F# {1}. Используйте версию языка {2} или выше. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 7ee5a8cb3bc..96313ad7db1 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -12,6 +12,11 @@ '{0}' kaynak dosyasının dosya uzantısı tanınmadı. Kaynak dosyaların uzantısı .fs, .fsi, .fsx veya .fsscript olmalıdır. + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. '{0}' özelliği F# {1} sürümünde kullanılamıyor. Lütfen {2} veya daha yüksek bir dil sürümünü kullanın. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 2659f03165a..305a7a5169a 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -12,6 +12,11 @@ 无法识别“{0}”的文件扩展名。源文件必须具有扩展名 .fs、.fsi、.fsx 或 .fsscript + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. 功能“{0}”在 F# {1} 中不可用。请使用 {2} 或更高的语言版本。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index f7f06f543fc..4d142660603 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -12,6 +12,11 @@ 無法辨識 '{0}' 的副檔名。來源檔案的副檔名必須是 .fs、.fsi、.fsx 或 .fsscript。 + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. F# {1} 中無法使用 '{0}' 功能。請使用語言版本 {2} 或更新的版本。 From 4f941833013254f02a3c84ec2eb026b45e5a3989 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 22 Sep 2022 20:40:26 +0200 Subject: [PATCH 02/12] Update CheckDeclarations and unit tests --- src/Compiler/Checking/CheckDeclarations.fs | 16 ++++++++++++++-- .../E_Abstract_ReusedParam.fs | 11 +++++++++++ .../MethodsAndProperties/MethodsAndProperties.fs | 15 ++++++++++++++- 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/E_Abstract_ReusedParam.fs diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 0e3b8a7973b..301ec00b183 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -3941,7 +3941,20 @@ module TcDeclarations = | SynMemberDefn.NestedType (range=m) :: _ -> errorR(Error(FSComp.SR.tcTypesCannotContainNestedTypes(), m)) | _ -> () | ds -> - // Classic class construction + // Check for duplicated parameters + ds + |> List.choose (function SynMemberDefn.AbstractSlot (x, _, m) -> Some(x, m) | _ -> None) + |> List.map(fun (slot, m) -> slot.SynInfo.ArgNames, m) + |> List.iter(fun (argNames, m) -> + argNames + |> List.groupBy id + |> List.filter (fun (_, elems) -> Seq.length elems > 1) + |> List.map fst + |> List.iter(fun argName -> + if argNames.Length > 0 then + errorR(Error((FSComp.SR.chkDuplicatedMethodParameter(argName), m))))) + + // Classic class construction let _, ds = List.takeUntil (allFalse [isMember;isAbstractSlot;isInterface;isInherit;isField;isTycon]) ds match ds with | SynMemberDefn.Member (range=m) :: _ -> errorR(InternalError("CheckMembersForm: List.takeUntil is wrong", m)) @@ -3955,7 +3968,6 @@ module TcDeclarations = | SynMemberDefn.ValField (range=m) :: _ | SynMemberDefn.NestedType (range=m) :: _ -> errorR(InternalError("CheckMembersForm: List.takeUntil is wrong", m)) | _ -> () - /// Separates the definition into core (shape) and body. /// diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/E_Abstract_ReusedParam.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/E_Abstract_ReusedParam.fs new file mode 100644 index 00000000000..f5c1c9cec3b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/E_Abstract_ReusedParam.fs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +type I = + // Tupled. + abstract M : i:int * i:int -> int + // Curried. + abstract N : i:int -> i:int -> int + // More than two. + abstract O : i:int * i: int * i:int -> int + // Multiple distinct names repeated. + abstract P : i:int * j:int * i:int * j:int -> int \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs index 363e045f26a..c5da84d6ca9 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs @@ -413,5 +413,18 @@ module MethodsAndProperties = compilation |> verifyCompileAndRun |> shouldSucceed - + + // SOURCE=E_Abstract_ReusedParam.fs # E_Abstract_ReusedParam.fs + [] + let ``E_Abstract_Methods_ReusedParam_fs`` compilation = + compilation + |> verifyCompile + |> shouldFail + |> withDiagnostics [ + (Error 3546, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + ] From c7be1949fe972107030a85d357c5aab1ee112ee4 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Fri, 23 Sep 2022 13:48:38 +0200 Subject: [PATCH 03/12] Fix PR suggestion --- src/Compiler/Checking/CheckDeclarations.fs | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 301ec00b183..f8225012864 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -3943,16 +3943,20 @@ module TcDeclarations = | ds -> // Check for duplicated parameters ds - |> List.choose (function SynMemberDefn.AbstractSlot (x, _, m) -> Some(x, m) | _ -> None) - |> List.map(fun (slot, m) -> slot.SynInfo.ArgNames, m) - |> List.iter(fun (argNames, m) -> - argNames - |> List.groupBy id - |> List.filter (fun (_, elems) -> Seq.length elems > 1) - |> List.map fst - |> List.iter(fun argName -> - if argNames.Length > 0 then - errorR(Error((FSComp.SR.chkDuplicatedMethodParameter(argName), m))))) + |> List.filter isAbstractSlot + |> List.iter(fun slot -> + match slot with + | SynMemberDefn.AbstractSlot (x, _, m) -> + let argNames = + x.SynInfo.ArgNames + |> List.groupBy id + |> List.filter (fun (_, elems) -> Seq.length elems > 1) + |> List.map fst + argNames + |> List.iter(fun argName -> + if argNames.Length > 0 then + errorR(Error((FSComp.SR.chkDuplicatedMethodParameter(argName), m)))) + | _ -> ()) // Classic class construction let _, ds = List.takeUntil (allFalse [isMember;isAbstractSlot;isInterface;isInherit;isField;isTycon]) ds From 71878738f337b128814520199b08dfd2f348008d Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Fri, 23 Sep 2022 22:52:35 +0200 Subject: [PATCH 04/12] Simplify logic basedon PR comments --- src/Compiler/Checking/CheckDeclarations.fs | 27 ++++++++++------------ 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index e867cb5cc52..62b56344064 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -3946,21 +3946,18 @@ module TcDeclarations = | _ -> () | ds -> // Check for duplicated parameters - ds - |> List.filter isAbstractSlot - |> List.iter(fun slot -> - match slot with - | SynMemberDefn.AbstractSlot (x, _, m) -> - let argNames = - x.SynInfo.ArgNames - |> List.groupBy id - |> List.filter (fun (_, elems) -> Seq.length elems > 1) - |> List.map fst - argNames - |> List.iter(fun argName -> - if argNames.Length > 0 then - errorR(Error((FSComp.SR.chkDuplicatedMethodParameter(argName), m)))) - | _ -> ()) + for slot in ds do + if isAbstractSlot slot then + match slot with + | SynMemberDefn.AbstractSlot (x, _, m) -> + let argNames = + x.SynInfo.ArgNames + |> List.groupBy id + |> List.filter (fun (_, elems) -> Seq.length elems > 1) + |> List.map fst + for name in argNames do + errorR(Error((FSComp.SR.chkDuplicatedMethodParameter(name), m))) + | _ -> () // Classic class construction let _, ds = List.takeUntil (allFalse [isMember;isAbstractSlot;isInterface;isInherit;isField;isTycon]) ds From 386454f50712ee06b61fd8a752a32dd19dbb254e Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sun, 25 Sep 2022 17:55:44 +0200 Subject: [PATCH 05/12] Add check for signature files --- src/Compiler/Checking/CheckDeclarations.fs | 24 ++++++++++- .../MethodsAndProperties.fs | 42 +++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 62b56344064..bd31706f827 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -386,6 +386,24 @@ let CheckNamespaceModuleOrTypeName (g: TcGlobals) (id: Ident) = if not g.compilingFSharpCore && id.idText.IndexOfAny IllegalCharactersInTypeAndNamespaceNames <> -1 then errorR(Error(FSComp.SR.tcInvalidNamespaceModuleTypeUnionName(), id.idRange)) +let CheckDuplicatesAbstractMethodParmsSig (typeSpecs: SynTypeDefnSig list) = + for SynTypeDefnSig(typeRepr= trepr) in typeSpecs do + match trepr with + | SynTypeDefnSigRepr.ObjectModel(_, synMemberSigs, _) -> + for sms in synMemberSigs do + match sms with + | SynMemberSig.Member(synValSig, _, m) -> + let argNames = + synValSig.SynInfo.ArgNames + |> List.groupBy id + |> List.filter (fun (_, elems) -> Seq.length elems > 1) + |> List.map fst + + for name in argNames do + errorR(Error((FSComp.SR.chkDuplicatedMethodParameter(name), m))) + | _ -> () + | _ -> () + let CheckDuplicates (idf: _ -> Ident) k elems = elems |> List.iteri (fun i uc1 -> elems |> List.iteri (fun j uc2 -> @@ -4363,7 +4381,8 @@ let rec TcSignatureElementNonMutRec (cenv: cenv) parent typeNames endm (env: TcE let _, _, _, env = TcExceptionDeclarations.TcExnSignature cenv env parent emptyUnscopedTyparEnv (edef, scopem) return env - | SynModuleSigDecl.Types (typeSpecs, m) -> + | SynModuleSigDecl.Types (typeSpecs, m) -> + CheckDuplicatesAbstractMethodParmsSig(typeSpecs) let scopem = unionRanges m endm let mutRecDefns = typeSpecs |> List.map MutRecShape.Tycon let env = TcDeclarations.TcMutRecSignatureDecls cenv env parent typeNames emptyUnscopedTyparEnv m scopem None mutRecDefns @@ -4533,7 +4552,8 @@ and TcSignatureElementsMutRec cenv parent typeNames m mutRecNSInfo envInitial (d let rec loop isNamespace moduleRange defs: MutRecSigsInitialData = ((true, true), defs) ||> List.collectFold (fun (openOk, moduleAbbrevOk) def -> match def with - | SynModuleSigDecl.Types (typeSpecs, _) -> + | SynModuleSigDecl.Types (typeSpecs, _) -> + CheckDuplicatesAbstractMethodParmsSig(typeSpecs) let decls = typeSpecs |> List.map MutRecShape.Tycon decls, (false, false) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs index c5da84d6ca9..6d8b6e1da20 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs @@ -427,4 +427,46 @@ module MethodsAndProperties = (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") ] + + [] + let ``Error in signature with abstract methods when reusing parameters`` () = + let encodeFsi = + Fsi """ +namespace rec Foo +type I = + // Tupled. + abstract M : i:int * i:int -> int + // Curried. + abstract N : i:int -> i:int -> int + // More than two. + abstract O : i:int * i: int * i:int -> int + // Multiple distinct names repeated. + abstract P : i:int * j:int * i:int * j:int -> int + """ + let encodeFs = + FsSource """ +namespace rec Foo +type I = + // Tupled. + abstract M : i:int * i:int -> int + // Curried. + abstract N : i:int -> i:int -> int + // More than two. + abstract O : i:int * i: int * i:int -> int + // Multiple distinct names repeated. + abstract P : i:int * j:int * i:int * j:int -> int + """ + encodeFsi + |> withAdditionalSourceFile encodeFs + |> asExe + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 3546, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + ] + From 0c69d967881f069c603d7db12e4157d174cf9f5a Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Mon, 26 Sep 2022 12:24:58 +0200 Subject: [PATCH 06/12] More updates --- src/Compiler/Checking/CheckDeclarations.fs | 35 +++--- .../MethodsAndProperties.fs | 101 +++++++++++++++++- 2 files changed, 113 insertions(+), 23 deletions(-) diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index bd31706f827..88d57f7e954 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -385,6 +385,15 @@ let CheckNamespaceModuleOrTypeName (g: TcGlobals) (id: Ident) = // type names '[]' etc. are used in fslib if not g.compilingFSharpCore && id.idText.IndexOfAny IllegalCharactersInTypeAndNamespaceNames <> -1 then errorR(Error(FSComp.SR.tcInvalidNamespaceModuleTypeUnionName(), id.idRange)) + +let CheckDuplicatesInSynValSig (synVal: SynValSig) m = + let argNames = + synVal.SynInfo.ArgNames + |> List.countBy id + |> List.filter (fun (_, count) -> count > 1) + |> List.map fst + for name in argNames do + errorR(Error((FSComp.SR.chkDuplicatedMethodParameter(name), m))) let CheckDuplicatesAbstractMethodParmsSig (typeSpecs: SynTypeDefnSig list) = for SynTypeDefnSig(typeRepr= trepr) in typeSpecs do @@ -393,14 +402,7 @@ let CheckDuplicatesAbstractMethodParmsSig (typeSpecs: SynTypeDefnSig list) = for sms in synMemberSigs do match sms with | SynMemberSig.Member(synValSig, _, m) -> - let argNames = - synValSig.SynInfo.ArgNames - |> List.groupBy id - |> List.filter (fun (_, elems) -> Seq.length elems > 1) - |> List.map fst - - for name in argNames do - errorR(Error((FSComp.SR.chkDuplicatedMethodParameter(name), m))) + CheckDuplicatesInSynValSig synValSig m | _ -> () | _ -> () @@ -3963,18 +3965,13 @@ module TcDeclarations = | SynMemberDefn.NestedType (range=m) :: _ -> errorR(Error(FSComp.SR.tcTypesCannotContainNestedTypes(), m)) | _ -> () | ds -> - // Check for duplicated parameters + + // Check for duplicated parameters in abstract methods for slot in ds do if isAbstractSlot slot then match slot with - | SynMemberDefn.AbstractSlot (x, _, m) -> - let argNames = - x.SynInfo.ArgNames - |> List.groupBy id - |> List.filter (fun (_, elems) -> Seq.length elems > 1) - |> List.map fst - for name in argNames do - errorR(Error((FSComp.SR.chkDuplicatedMethodParameter(name), m))) + | SynMemberDefn.AbstractSlot (synVal, _, m) -> + CheckDuplicatesInSynValSig synVal m | _ -> () // Classic class construction @@ -4382,7 +4379,7 @@ let rec TcSignatureElementNonMutRec (cenv: cenv) parent typeNames endm (env: TcE return env | SynModuleSigDecl.Types (typeSpecs, m) -> - CheckDuplicatesAbstractMethodParmsSig(typeSpecs) + CheckDuplicatesAbstractMethodParmsSig typeSpecs let scopem = unionRanges m endm let mutRecDefns = typeSpecs |> List.map MutRecShape.Tycon let env = TcDeclarations.TcMutRecSignatureDecls cenv env parent typeNames emptyUnscopedTyparEnv m scopem None mutRecDefns @@ -4553,7 +4550,7 @@ and TcSignatureElementsMutRec cenv parent typeNames m mutRecNSInfo envInitial (d ((true, true), defs) ||> List.collectFold (fun (openOk, moduleAbbrevOk) def -> match def with | SynModuleSigDecl.Types (typeSpecs, _) -> - CheckDuplicatesAbstractMethodParmsSig(typeSpecs) + CheckDuplicatesAbstractMethodParmsSig typeSpecs let decls = typeSpecs |> List.map MutRecShape.Tycon decls, (false, false) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs index 6d8b6e1da20..3a6b49ea1d5 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs @@ -429,10 +429,64 @@ module MethodsAndProperties = ] [] - let ``Error in signature with abstract methods when reusing parameters`` () = + let ``Error in signature file with not implementation file with abstract methods when reusing parameters`` () = + let encodeFsi = + Fsi """ +namespace Foo +type I = + // Tupled. + abstract M : i:int * i:int -> int + // Curried. + abstract N : i:int -> i:int -> int + // More than two. + abstract O : i:int * i: int * i:int -> int + // Multiple distinct names repeated. + abstract P : i:int * j:int * i:int * j:int -> int + """ + encodeFsi + |> verifyCompile + |> shouldFail + |> withDiagnostics [ + (Error 3546, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 240, Line 2, Col 1, Line 11, Col 54, "The signature file 'Test' does not have a corresponding implementation file. If an implementation file exists then check the 'module' and 'namespace' declarations in the signature and implementation files match.") + ] + + [] + let ``Error in signature file with not implementation file with abstract methods when reusing parameters in recursive namespace`` () = let encodeFsi = Fsi """ namespace rec Foo +type I = + // Tupled. + abstract M : i:int * i:int -> int + // Curried. + abstract N : i:int -> i:int -> int + // More than two. + abstract O : i:int * i: int * i:int -> int + // Multiple distinct names repeated. + abstract P : i:int * j:int * i:int * j:int -> int + """ + encodeFsi + |> verifyCompile + |> shouldFail + |> withDiagnostics [ + (Error 3546, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 240, Line 2, Col 1, Line 11, Col 54, "The signature file 'Test' does not have a corresponding implementation file. If an implementation file exists then check the 'module' and 'namespace' declarations in the signature and implementation files match.") + ] + + [] + let ``Errors in signature and implementation files with abstract methods when reusing parameters`` () = + let encodeFsi = + Fsi """ +namespace Foo type I = // Tupled. abstract M : i:int * i:int -> int @@ -445,6 +499,34 @@ type I = """ let encodeFs = FsSource """ +namespace Foo +type I = + abstract M : i:int * i:int -> int + abstract N : i:int -> i:int -> int + abstract O : i:int * i: int * i:int -> int + abstract P : i:int * j:int * i:int * j:int -> int + """ + encodeFsi + |> withAdditionalSourceFile encodeFs + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 3546, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 3546, Line 4, Col 5, Line 4, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 5, Col 5, Line 5, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 6, Col 5, Line 6, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + ] + + [] + let ``Errors in signature and implementation files with abstract methods when reusing parameters in recursive namespaces`` () = + let encodeFsi = + Fsi """ namespace rec Foo type I = // Tupled. @@ -454,11 +536,19 @@ type I = // More than two. abstract O : i:int * i: int * i:int -> int // Multiple distinct names repeated. + abstract P : i:int * j:int * i:int * j:int -> int + """ + let encodeFs = + FsSource """ +namespace rec Foo +type I = + abstract M : i:int * i:int -> int + abstract N : i:int -> i:int -> int + abstract O : i:int * i: int * i:int -> int abstract P : i:int * j:int * i:int * j:int -> int """ encodeFsi |> withAdditionalSourceFile encodeFs - |> asExe |> compile |> shouldFail |> withDiagnostics [ @@ -467,6 +557,9 @@ type I = (Error 3546, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 3546, Line 4, Col 5, Line 4, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 5, Col 5, Line 5, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 6, Col 5, Line 6, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3546, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") ] - - From 242b2147de114c62db56b656b6b1c6960c60952b Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Fri, 30 Sep 2022 11:38:01 +0200 Subject: [PATCH 07/12] Fix conflicts in FSComp.txt --- .../MethodsAndProperties.fs | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs index 3a6b49ea1d5..6988a91b503 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs @@ -421,11 +421,11 @@ module MethodsAndProperties = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 3546, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 3548, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") ] [] @@ -447,11 +447,11 @@ type I = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 3546, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 3548, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") (Error 240, Line 2, Col 1, Line 11, Col 54, "The signature file 'Test' does not have a corresponding implementation file. If an implementation file exists then check the 'module' and 'namespace' declarations in the signature and implementation files match.") ] @@ -474,11 +474,11 @@ type I = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 3546, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 3548, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") (Error 240, Line 2, Col 1, Line 11, Col 54, "The signature file 'Test' does not have a corresponding implementation file. If an implementation file exists then check the 'module' and 'namespace' declarations in the signature and implementation files match.") ] @@ -511,16 +511,16 @@ type I = |> compile |> shouldFail |> withDiagnostics [ - (Error 3546, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") - (Error 3546, Line 4, Col 5, Line 4, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 5, Col 5, Line 5, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 6, Col 5, Line 6, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 3548, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 3548, Line 4, Col 5, Line 4, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 5, Col 5, Line 5, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 6, Col 5, Line 6, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") ] [] @@ -552,14 +552,14 @@ type I = |> compile |> shouldFail |> withDiagnostics [ - (Error 3546, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") - (Error 3546, Line 4, Col 5, Line 4, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 5, Col 5, Line 5, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 6, Col 5, Line 6, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3546, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 3548, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 3548, Line 4, Col 5, Line 4, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 5, Col 5, Line 5, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 6, Col 5, Line 6, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3548, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") ] From b4cb2f366e382ac02f915f5f76a42de723247d20 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 5 Oct 2022 14:43:04 +0200 Subject: [PATCH 08/12] Add a fix for Duplicate member signature error is not reported in signature files --- src/Compiler/Checking/CheckDeclarations.fs | 36 ++++++++++++++++--- .../MethodsAndProperties.fs | 19 ++++++++++ 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index e6e29f51001..5f95911b99b 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -386,7 +386,7 @@ let CheckNamespaceModuleOrTypeName (g: TcGlobals) (id: Ident) = if not g.compilingFSharpCore && id.idText.IndexOfAny IllegalCharactersInTypeAndNamespaceNames <> -1 then errorR(Error(FSComp.SR.tcInvalidNamespaceModuleTypeUnionName(), id.idRange)) -let CheckDuplicatesInSynValSig (synVal: SynValSig) m = +let CheckDuplicatesArgNames (synVal: SynValSig) m = let argNames = synVal.SynInfo.ArgNames |> List.countBy id @@ -394,15 +394,43 @@ let CheckDuplicatesInSynValSig (synVal: SynValSig) m = |> List.map fst for name in argNames do errorR(Error((FSComp.SR.chkDuplicatedMethodParameter(name), m))) + +let CheckDuplicateMemberNames (typeInfo: SynComponentInfo) (synMembersSig: SynMemberSig list) m= + let (SynComponentInfo(longId = longId)) = typeInfo + let synMembers = + synMembersSig + |> List.choose(fun sms -> + match sms with + | SynMemberSig.Member(memberSig = synValSig) -> + match synValSig with + | SynValSig(ident = SynIdent(ident, _)) -> + Some ident.idText + | _ -> None) + + let memberNames = + synMembers + |> List.countBy id + |> List.filter (fun (_, count) -> count > 1) + |> List.map fst + + let typeName = + longId + |> List.tryHead + |> Option.map(fun ident -> ident.idText) + |> Option.defaultValue "" + + for name in memberNames do + errorR(Error((FSComp.SR.chkDuplicateMethod(name, typeName), m))) let CheckDuplicatesAbstractMethodParmsSig (typeSpecs: SynTypeDefnSig list) = - for SynTypeDefnSig(typeRepr= trepr) in typeSpecs do + for SynTypeDefnSig(typeInfo= typeInfo; typeRepr= trepr) in typeSpecs do match trepr with | SynTypeDefnSigRepr.ObjectModel(_, synMemberSigs, _) -> for sms in synMemberSigs do match sms with | SynMemberSig.Member(synValSig, _, m) -> - CheckDuplicatesInSynValSig synValSig m + CheckDuplicatesArgNames synValSig m + CheckDuplicateMemberNames typeInfo synMemberSigs m | _ -> () | _ -> () @@ -3972,7 +4000,7 @@ module TcDeclarations = if isAbstractSlot slot then match slot with | SynMemberDefn.AbstractSlot (synVal, _, m) -> - CheckDuplicatesInSynValSig synVal m + CheckDuplicatesArgNames synVal m | _ -> () // Classic class construction diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs index 6988a91b503..56f23122ea6 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs @@ -428,6 +428,25 @@ module MethodsAndProperties = (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") ] + [] + let ``Duplicate member signature error is reported in signature files`` () = + let encodeFsi = + Fsi """ +namespace Foo +[] +type FSharpMemberOrFunctionOrValue = + member IsFunction: bool + member IsFunction: bool + """ + encodeFsi + |> verifyCompile + |> shouldFail + |> withDiagnostics [ + (Error 438, Line 5, Col 5, Line 5, Col 28, "Duplicate method. The method 'IsFunction' has the same name and signature as another method in type 'FSharpMemberOrFunctionOrValue'.") + (Error 438, Line 6, Col 5, Line 6, Col 28, "Duplicate method. The method 'IsFunction' has the same name and signature as another method in type 'FSharpMemberOrFunctionOrValue'.") + (Error 240, Line 2, Col 1, Line 6, Col 28, "The signature file 'Test' does not have a corresponding implementation file. If an implementation file exists then check the 'module' and 'namespace' declarations in the signature and implementation files match.") + ] + [] let ``Error in signature file with not implementation file with abstract methods when reusing parameters`` () = let encodeFsi = From 5174c80b8d670357419dae59676468066f958dff Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 5 Oct 2022 19:18:53 +0200 Subject: [PATCH 09/12] Fix PR comments --- src/Compiler/Checking/CheckDeclarations.fs | 73 ++++++++----------- src/Compiler/SyntaxTree/SyntaxTree.fs | 4 + src/Compiler/SyntaxTree/SyntaxTree.fsi | 2 + .../MethodsAndProperties.fs | 7 +- 4 files changed, 39 insertions(+), 47 deletions(-) diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 5f95911b99b..79aec5650c1 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -381,69 +381,54 @@ exception NotUpperCaseConstructor of range: range exception NotUpperCaseConstructorWithoutRQA of range: range + +let CheckDuplicates (idf: _ -> Ident) k elems = + elems |> List.iteri (fun i uc1 -> + elems |> List.iteri (fun j uc2 -> + let id1 = (idf uc1) + let id2 = (idf uc2) + if j > i && id1.idText = id2.idText then + errorR (Duplicate(k, id1.idText, id1.idRange)))) + elems + let CheckNamespaceModuleOrTypeName (g: TcGlobals) (id: Ident) = // type names '[]' etc. are used in fslib if not g.compilingFSharpCore && id.idText.IndexOfAny IllegalCharactersInTypeAndNamespaceNames <> -1 then errorR(Error(FSComp.SR.tcInvalidNamespaceModuleTypeUnionName(), id.idRange)) let CheckDuplicatesArgNames (synVal: SynValSig) m = - let argNames = - synVal.SynInfo.ArgNames - |> List.countBy id - |> List.filter (fun (_, count) -> count > 1) - |> List.map fst + let argNames = synVal.SynInfo.ArgNames |> List.duplicates for name in argNames do errorR(Error((FSComp.SR.chkDuplicatedMethodParameter(name), m))) -let CheckDuplicateMemberNames (typeInfo: SynComponentInfo) (synMembersSig: SynMemberSig list) m= - let (SynComponentInfo(longId = longId)) = typeInfo - let synMembers = +let CheckDuplicateMemberNames (synMembersSig: SynMemberSig list) = + let synValSig = synMembersSig - |> List.choose(fun sms -> - match sms with - | SynMemberSig.Member(memberSig = synValSig) -> - match synValSig with - | SynValSig(ident = SynIdent(ident, _)) -> - Some ident.idText - | _ -> None) + |> List.choose( + fun synMember -> + match synMember with + | SynMemberSig.Member(synValSig, synMemberFlags, _) + when not synMemberFlags.IsConstructor -> Some(synValSig) + |_ -> None) let memberNames = - synMembers - |> List.countBy id - |> List.filter (fun (_, count) -> count > 1) - |> List.map fst - - let typeName = - longId - |> List.tryHead - |> Option.map(fun ident -> ident.idText) - |> Option.defaultValue "" + synValSig + |> List.choose(function SynValSig(ident = SynIdent(ident, _)) -> Some(ident)) - for name in memberNames do - errorR(Error((FSComp.SR.chkDuplicateMethod(name, typeName), m))) + memberNames |> CheckDuplicates id "member" |> ignore let CheckDuplicatesAbstractMethodParmsSig (typeSpecs: SynTypeDefnSig list) = - for SynTypeDefnSig(typeInfo= typeInfo; typeRepr= trepr) in typeSpecs do + for SynTypeDefnSig(typeRepr= trepr) in typeSpecs do match trepr with | SynTypeDefnSigRepr.ObjectModel(_, synMemberSigs, _) -> - for sms in synMemberSigs do - match sms with - | SynMemberSig.Member(synValSig, _, m) -> - CheckDuplicatesArgNames synValSig m - CheckDuplicateMemberNames typeInfo synMemberSigs m - | _ -> () + CheckDuplicateMemberNames synMemberSigs + for sms in synMemberSigs do + match sms with + | SynMemberSig.Member(synValSig, _, m) -> + CheckDuplicatesArgNames synValSig m + | _ -> () | _ -> () -let CheckDuplicates (idf: _ -> Ident) k elems = - elems |> List.iteri (fun i uc1 -> - elems |> List.iteri (fun j uc2 -> - let id1 = (idf uc1) - let id2 = (idf uc2) - if j > i && id1.idText = id2.idText then - errorR (Duplicate(k, id1.idText, id1.idRange)))) - elems - - module TcRecdUnionAndEnumDeclarations = let CombineReprAccess parent vis = diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fs b/src/Compiler/SyntaxTree/SyntaxTree.fs index 11c0c28375b..508f6199c34 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fs +++ b/src/Compiler/SyntaxTree/SyntaxTree.fs @@ -1079,6 +1079,10 @@ type SynMemberFlags = Trivia: SynMemberFlagsTrivia } + + member this.IsConstructor = + this.MemberKind = SynMemberKind.Constructor + || this.MemberKind = SynMemberKind.ClassConstructor override this.Equals other = match other with diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fsi b/src/Compiler/SyntaxTree/SyntaxTree.fsi index 2a34ba55c46..3f65c846282 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTree.fsi @@ -1231,6 +1231,8 @@ type SynMemberFlags = Trivia: SynMemberFlagsTrivia } + member IsConstructor: bool + /// Note the member kind is actually computed partially by a syntax tree transformation in tc.fs [] type SynMemberKind = diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs index 56f23122ea6..c5bd5733245 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs @@ -435,6 +435,8 @@ module MethodsAndProperties = namespace Foo [] type FSharpMemberOrFunctionOrValue = + new : unit -> int + new : int -> string member IsFunction: bool member IsFunction: bool """ @@ -442,9 +444,8 @@ type FSharpMemberOrFunctionOrValue = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 438, Line 5, Col 5, Line 5, Col 28, "Duplicate method. The method 'IsFunction' has the same name and signature as another method in type 'FSharpMemberOrFunctionOrValue'.") - (Error 438, Line 6, Col 5, Line 6, Col 28, "Duplicate method. The method 'IsFunction' has the same name and signature as another method in type 'FSharpMemberOrFunctionOrValue'.") - (Error 240, Line 2, Col 1, Line 6, Col 28, "The signature file 'Test' does not have a corresponding implementation file. If an implementation file exists then check the 'module' and 'namespace' declarations in the signature and implementation files match.") + (Error 37, Line 7, Col 12, Line 7, Col 22, "Two members called 'IsFunction' have the same signature") + (Error 240, Line 2, Col 1, Line 8, Col 28, "The signature file 'Test' does not have a corresponding implementation file. If an implementation file exists then check the 'module' and 'namespace' declarations in the signature and implementation files match.") ] [] From f2efc8f995de39bc0aafd097fea644422565bb6d Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Tue, 11 Oct 2022 17:56:32 +0200 Subject: [PATCH 10/12] Focus only on fixing #13148 --- src/Compiler/Checking/CheckDeclarations.fs | 35 +++++-------------- src/Compiler/SyntaxTree/SyntaxTree.fs | 4 --- src/Compiler/SyntaxTree/SyntaxTree.fsi | 2 -- .../MethodsAndProperties.fs | 20 ----------- 4 files changed, 9 insertions(+), 52 deletions(-) diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 79aec5650c1..080c4ab05d6 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -396,37 +396,20 @@ let CheckNamespaceModuleOrTypeName (g: TcGlobals) (id: Ident) = if not g.compilingFSharpCore && id.idText.IndexOfAny IllegalCharactersInTypeAndNamespaceNames <> -1 then errorR(Error(FSComp.SR.tcInvalidNamespaceModuleTypeUnionName(), id.idRange)) -let CheckDuplicatesArgNames (synVal: SynValSig) m = +let private CheckDuplicatesArgNames (synVal: SynValSig) m = let argNames = synVal.SynInfo.ArgNames |> List.duplicates for name in argNames do errorR(Error((FSComp.SR.chkDuplicatedMethodParameter(name), m))) - -let CheckDuplicateMemberNames (synMembersSig: SynMemberSig list) = - let synValSig = - synMembersSig - |> List.choose( - fun synMember -> - match synMember with - | SynMemberSig.Member(synValSig, synMemberFlags, _) - when not synMemberFlags.IsConstructor -> Some(synValSig) - |_ -> None) - - let memberNames = - synValSig - |> List.choose(function SynValSig(ident = SynIdent(ident, _)) -> Some(ident)) - - memberNames |> CheckDuplicates id "member" |> ignore - -let CheckDuplicatesAbstractMethodParmsSig (typeSpecs: SynTypeDefnSig list) = - for SynTypeDefnSig(typeRepr= trepr) in typeSpecs do + +let private CheckDuplicatesAbstractMethodParmsSig (typeSpecs: SynTypeDefnSig list) = + for SynTypeDefnSig(typeRepr= trepr) in typeSpecs do match trepr with | SynTypeDefnSigRepr.ObjectModel(_, synMemberSigs, _) -> - CheckDuplicateMemberNames synMemberSigs - for sms in synMemberSigs do - match sms with - | SynMemberSig.Member(synValSig, _, m) -> - CheckDuplicatesArgNames synValSig m - | _ -> () + for sms in synMemberSigs do + match sms with + | SynMemberSig.Member(synValSig, _, m) -> + CheckDuplicatesArgNames synValSig m + | _ -> () | _ -> () module TcRecdUnionAndEnumDeclarations = diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fs b/src/Compiler/SyntaxTree/SyntaxTree.fs index 68114a1d3f5..9412e8486ae 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fs +++ b/src/Compiler/SyntaxTree/SyntaxTree.fs @@ -1082,10 +1082,6 @@ type SynMemberFlags = Trivia: SynMemberFlagsTrivia } - - member this.IsConstructor = - this.MemberKind = SynMemberKind.Constructor - || this.MemberKind = SynMemberKind.ClassConstructor override this.Equals other = match other with diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fsi b/src/Compiler/SyntaxTree/SyntaxTree.fsi index fe5aa941cf5..1dfd44d2c0f 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTree.fsi @@ -1234,8 +1234,6 @@ type SynMemberFlags = Trivia: SynMemberFlagsTrivia } - member IsConstructor: bool - /// Note the member kind is actually computed partially by a syntax tree transformation in tc.fs [] type SynMemberKind = diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs index c5bd5733245..6988a91b503 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs @@ -428,26 +428,6 @@ module MethodsAndProperties = (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") ] - [] - let ``Duplicate member signature error is reported in signature files`` () = - let encodeFsi = - Fsi """ -namespace Foo -[] -type FSharpMemberOrFunctionOrValue = - new : unit -> int - new : int -> string - member IsFunction: bool - member IsFunction: bool - """ - encodeFsi - |> verifyCompile - |> shouldFail - |> withDiagnostics [ - (Error 37, Line 7, Col 12, Line 7, Col 22, "Two members called 'IsFunction' have the same signature") - (Error 240, Line 2, Col 1, Line 8, Col 28, "The signature file 'Test' does not have a corresponding implementation file. If an implementation file exists then check the 'module' and 'namespace' declarations in the signature and implementation files match.") - ] - [] let ``Error in signature file with not implementation file with abstract methods when reusing parameters`` () = let encodeFsi = From 231f9e0d76e9ec66d35ddd178aa5bb0cdfc3e614 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Tue, 11 Oct 2022 18:11:24 +0200 Subject: [PATCH 11/12] Avoid moving functions to reduce diiff --- src/Compiler/Checking/CheckDeclarations.fs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 080c4ab05d6..21506cfaebe 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -381,7 +381,11 @@ exception NotUpperCaseConstructor of range: range exception NotUpperCaseConstructorWithoutRQA of range: range - +let CheckNamespaceModuleOrTypeName (g: TcGlobals) (id: Ident) = + // type names '[]' etc. are used in fslib + if not g.compilingFSharpCore && id.idText.IndexOfAny IllegalCharactersInTypeAndNamespaceNames <> -1 then + errorR(Error(FSComp.SR.tcInvalidNamespaceModuleTypeUnionName(), id.idRange)) + let CheckDuplicates (idf: _ -> Ident) k elems = elems |> List.iteri (fun i uc1 -> elems |> List.iteri (fun j uc2 -> @@ -390,11 +394,6 @@ let CheckDuplicates (idf: _ -> Ident) k elems = if j > i && id1.idText = id2.idText then errorR (Duplicate(k, id1.idText, id1.idRange)))) elems - -let CheckNamespaceModuleOrTypeName (g: TcGlobals) (id: Ident) = - // type names '[]' etc. are used in fslib - if not g.compilingFSharpCore && id.idText.IndexOfAny IllegalCharactersInTypeAndNamespaceNames <> -1 then - errorR(Error(FSComp.SR.tcInvalidNamespaceModuleTypeUnionName(), id.idRange)) let private CheckDuplicatesArgNames (synVal: SynValSig) m = let argNames = synVal.SynInfo.ArgNames |> List.duplicates From d843926b890283528529d259772b33dafb047cac Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Tue, 11 Oct 2022 18:14:27 +0200 Subject: [PATCH 12/12] Update Error number after rebasing from main --- .../MethodsAndProperties.fs | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs index 6988a91b503..a8a1471fa4e 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs @@ -421,11 +421,11 @@ module MethodsAndProperties = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 3548, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 3549, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") ] [] @@ -447,11 +447,11 @@ type I = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 3548, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 3549, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") (Error 240, Line 2, Col 1, Line 11, Col 54, "The signature file 'Test' does not have a corresponding implementation file. If an implementation file exists then check the 'module' and 'namespace' declarations in the signature and implementation files match.") ] @@ -474,11 +474,11 @@ type I = |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 3548, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 3549, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") (Error 240, Line 2, Col 1, Line 11, Col 54, "The signature file 'Test' does not have a corresponding implementation file. If an implementation file exists then check the 'module' and 'namespace' declarations in the signature and implementation files match.") ] @@ -511,16 +511,16 @@ type I = |> compile |> shouldFail |> withDiagnostics [ - (Error 3548, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") - (Error 3548, Line 4, Col 5, Line 4, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 5, Col 5, Line 5, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 6, Col 5, Line 6, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 3549, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 3549, Line 4, Col 5, Line 4, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 5, Col 5, Line 5, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 6, Col 5, Line 6, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") ] [] @@ -552,14 +552,14 @@ type I = |> compile |> shouldFail |> withDiagnostics [ - (Error 3548, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") - (Error 3548, Line 4, Col 5, Line 4, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 5, Col 5, Line 5, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 6, Col 5, Line 6, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") - (Error 3548, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 3549, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 3549, Line 4, Col 5, Line 4, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 5, Col 5, Line 5, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 6, Col 5, Line 6, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3549, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") ]