Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e268376
Update FSComp to add a new error message
edgarfgp Sep 22, 2022
4f94183
Update CheckDeclarations and unit tests
edgarfgp Sep 22, 2022
11dd995
Merge branch 'main' into compiler-error-when-declaring-multiple-param…
edgarfgp Sep 23, 2022
c7be194
Fix PR suggestion
edgarfgp Sep 23, 2022
f4a9148
Merge branch 'main' into compiler-error-when-declaring-multiple-param…
edgarfgp Sep 23, 2022
7187873
Simplify logic basedon PR comments
edgarfgp Sep 23, 2022
451833b
Merge branch 'main' into compiler-error-when-declaring-multiple-param…
dsyme Sep 24, 2022
386454f
Add check for signature files
edgarfgp Sep 25, 2022
bb86563
Merge branch 'compiler-error-when-declaring-multiple-parameters-with-…
edgarfgp Sep 25, 2022
0c69d96
More updates
edgarfgp Sep 26, 2022
f726504
Merge branch 'main' into compiler-error-when-declaring-multiple-param…
edgarfgp Sep 26, 2022
3b96681
Merge branch 'main' into compiler-error-when-declaring-multiple-param…
edgarfgp Sep 30, 2022
242b214
Fix conflicts in FSComp.txt
edgarfgp Sep 30, 2022
60216a8
Merge branch 'main' into compiler-error-when-declaring-multiple-param…
edgarfgp Oct 3, 2022
ad4c04f
Merge branch 'main' into compiler-error-when-declaring-multiple-param…
edgarfgp Oct 3, 2022
9caf0c0
Merge branch 'main' into compiler-error-when-declaring-multiple-param…
edgarfgp Oct 3, 2022
0705160
Merge branch 'main' into compiler-error-when-declaring-multiple-param…
edgarfgp Oct 4, 2022
b4cb2f3
Add a fix for Duplicate member signature error is not reported in sig…
edgarfgp Oct 5, 2022
5174c80
Fix PR comments
edgarfgp Oct 5, 2022
b3271a4
Merge branch 'main' into compiler-error-when-declaring-multiple-param…
edgarfgp Oct 7, 2022
f2efc8f
Focus only on fixing #13148
edgarfgp Oct 11, 2022
724a3b5
Merge branch 'main' into compiler-error-when-declaring-multiple-param…
edgarfgp Oct 11, 2022
231f9e0
Avoid moving functions to reduce diiff
edgarfgp Oct 11, 2022
d843926
Update Error number after rebasing from main
edgarfgp Oct 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions src/Compiler/Checking/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ 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 ->
Expand All @@ -394,7 +394,22 @@ let CheckDuplicates (idf: _ -> Ident) k elems =
if j > i && id1.idText = id2.idText then
errorR (Duplicate(k, id1.idText, id1.idRange))))
elems


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 private 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) ->
CheckDuplicatesArgNames synValSig m
| _ -> ()
| _ -> ()

module TcRecdUnionAndEnumDeclarations =

Expand Down Expand Up @@ -3946,7 +3961,16 @@ module TcDeclarations =
| SynMemberDefn.NestedType (range=m) :: _ -> errorR(Error(FSComp.SR.tcTypesCannotContainNestedTypes(), m))
| _ -> ()
| ds ->
// Classic class construction

// Check for duplicated parameters in abstract methods
for slot in ds do
if isAbstractSlot slot then
match slot with
| SynMemberDefn.AbstractSlot (synVal, _, m) ->
CheckDuplicatesArgNames synVal 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))
Expand All @@ -3960,7 +3984,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.
///
Expand Down Expand Up @@ -4351,7 +4374,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
Expand Down Expand Up @@ -4521,7 +4545,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)

Expand Down
2 changes: 2 additions & 0 deletions src/Compiler/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1656,3 +1656,5 @@ reprStateMachineInvalidForm,"The state machine has an unexpected form"
3546,parsExpectingPatternInTuple,"Expecting pattern"
3547,parsExpectedPatternAfterToken,"Expected a pattern after this point"
3548,matchNotAllowedForUnionCaseWithNoData,"Pattern discard is not allowed for union case that takes no data."
3549,chkDuplicatedMethodParameter,"Duplicate parameter. The parameter '%s' has been used more that once in this method."

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<target state="translated">Soubor {0} má nerozpoznanou příponu. Zdrojové soubory musí mít příponu .fs, .fsi, .fsx nebo .fsscript.</target>
<note />
</trans-unit>
<trans-unit id="chkDuplicatedMethodParameter">
<source>Duplicate parameter. The parameter '{0}' has been used more that once in this method.</source>
<target state="new">Duplicate parameter. The parameter '{0}' has been used more that once in this method.</target>
<note />
</trans-unit>
<trans-unit id="chkFeatureNotLanguageSupported">
<source>Feature '{0}' is not available in F# {1}. Please use language version {2} or greater.</source>
<target state="translated">Funkce {0} není v jazyce F# {1} dostupná. Použijte prosím jazyk verze {2} nebo vyšší.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<target state="translated">Die Dateierweiterung von „{0}“ wurde nicht erkannt. Quelldateien müssen die Erweiterung .fs, .fsi, .fsx oder .fsscript haben</target>
<note />
</trans-unit>
<trans-unit id="chkDuplicatedMethodParameter">
<source>Duplicate parameter. The parameter '{0}' has been used more that once in this method.</source>
<target state="new">Duplicate parameter. The parameter '{0}' has been used more that once in this method.</target>
<note />
</trans-unit>
<trans-unit id="chkFeatureNotLanguageSupported">
<source>Feature '{0}' is not available in F# {1}. Please use language version {2} or greater.</source>
<target state="translated">Das Feature "{0}" ist in F# {1} nicht verfügbar. Verwenden Sie Sprachversion {2} oder höher.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<target state="translated">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</target>
<note />
</trans-unit>
<trans-unit id="chkDuplicatedMethodParameter">
<source>Duplicate parameter. The parameter '{0}' has been used more that once in this method.</source>
<target state="new">Duplicate parameter. The parameter '{0}' has been used more that once in this method.</target>
<note />
</trans-unit>
<trans-unit id="chkFeatureNotLanguageSupported">
<source>Feature '{0}' is not available in F# {1}. Please use language version {2} or greater.</source>
<target state="translated">La característica "{0}" no está disponible en F# {1}. Use la versión {2} del lenguaje o una posterior.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<target state="translated">L'extension de fichier de '{0}' n'est pas reconnue. Les fichiers sources doivent avoir l'extension .fs, .fsi, .fsx, ou .fsscript.</target>
<note />
</trans-unit>
<trans-unit id="chkDuplicatedMethodParameter">
<source>Duplicate parameter. The parameter '{0}' has been used more that once in this method.</source>
<target state="new">Duplicate parameter. The parameter '{0}' has been used more that once in this method.</target>
<note />
</trans-unit>
<trans-unit id="chkFeatureNotLanguageSupported">
<source>Feature '{0}' is not available in F# {1}. Please use language version {2} or greater.</source>
<target state="translated">La fonctionnalité '{0}' n'est pas disponible en F# {1}. Utilisez la version de langage {2} ou une version ultérieure.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<target state="translated">Estensione di file di '{0}' non riconosciuta. I file di origine devono avere estensione .fs, .fsi, .fsx or .fsscript</target>
<note />
</trans-unit>
<trans-unit id="chkDuplicatedMethodParameter">
<source>Duplicate parameter. The parameter '{0}' has been used more that once in this method.</source>
<target state="new">Duplicate parameter. The parameter '{0}' has been used more that once in this method.</target>
<note />
</trans-unit>
<trans-unit id="chkFeatureNotLanguageSupported">
<source>Feature '{0}' is not available in F# {1}. Please use language version {2} or greater.</source>
<target state="translated">La funzionalità '{0}' non è disponibile in F# {1}. Usare la versione {2} o versioni successive del linguaggio.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<target state="translated">'{0}' のファイル拡張子は認識されません。ソース ファイルの拡張子は .fs、.fsi、.fsx、または .fsscript にする必要があります。</target>
<note />
</trans-unit>
<trans-unit id="chkDuplicatedMethodParameter">
<source>Duplicate parameter. The parameter '{0}' has been used more that once in this method.</source>
<target state="new">Duplicate parameter. The parameter '{0}' has been used more that once in this method.</target>
<note />
</trans-unit>
<trans-unit id="chkFeatureNotLanguageSupported">
<source>Feature '{0}' is not available in F# {1}. Please use language version {2} or greater.</source>
<target state="translated">機能 '{0}' は F# {1} では使用できません。{2} 以上の言語バージョンをお使いください。</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<target state="translated">'{0}'의 파일 확장명을 인식할 수 없습니다. 원본 파일의 확장명은 .fs, .fsi, .fsx 또는 .fsscript여야 합니다.</target>
<note />
</trans-unit>
<trans-unit id="chkDuplicatedMethodParameter">
<source>Duplicate parameter. The parameter '{0}' has been used more that once in this method.</source>
<target state="new">Duplicate parameter. The parameter '{0}' has been used more that once in this method.</target>
<note />
</trans-unit>
<trans-unit id="chkFeatureNotLanguageSupported">
<source>Feature '{0}' is not available in F# {1}. Please use language version {2} or greater.</source>
<target state="translated">'{0}' 기능은 F# {1}에서 사용할 수 없습니다. {2} 이상의 언어 버전을 사용하세요.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<target state="translated">Rozszerzenie pliku "{0}" nie zostało rozpoznane. Pliki źródłowe muszą mieć rozszerzenie .fs, .fsi, .fsx lub .fsscript</target>
<note />
</trans-unit>
<trans-unit id="chkDuplicatedMethodParameter">
<source>Duplicate parameter. The parameter '{0}' has been used more that once in this method.</source>
<target state="new">Duplicate parameter. The parameter '{0}' has been used more that once in this method.</target>
<note />
</trans-unit>
<trans-unit id="chkFeatureNotLanguageSupported">
<source>Feature '{0}' is not available in F# {1}. Please use language version {2} or greater.</source>
<target state="translated">Funkcja „{0}” nie jest dostępna w języku F# {1}. Użyj języka w wersji {2} lub nowszej.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<target state="translated">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</target>
<note />
</trans-unit>
<trans-unit id="chkDuplicatedMethodParameter">
<source>Duplicate parameter. The parameter '{0}' has been used more that once in this method.</source>
<target state="new">Duplicate parameter. The parameter '{0}' has been used more that once in this method.</target>
<note />
</trans-unit>
<trans-unit id="chkFeatureNotLanguageSupported">
<source>Feature '{0}' is not available in F# {1}. Please use language version {2} or greater.</source>
<target state="translated">O recurso '{0}' não está disponível no F# {1}. Use a versão da linguagem {2} ou superior.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<target state="translated">Расширение файла "{0}" не распознано. Исходные файлы должны иметь расширения FS, FSI, FSX или FSSCRIPT</target>
<note />
</trans-unit>
<trans-unit id="chkDuplicatedMethodParameter">
<source>Duplicate parameter. The parameter '{0}' has been used more that once in this method.</source>
<target state="new">Duplicate parameter. The parameter '{0}' has been used more that once in this method.</target>
<note />
</trans-unit>
<trans-unit id="chkFeatureNotLanguageSupported">
<source>Feature '{0}' is not available in F# {1}. Please use language version {2} or greater.</source>
<target state="translated">Компонент "{0}" недоступен в F# {1}. Используйте версию языка {2} или выше.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<target state="translated">'{0}' kaynak dosyasının dosya uzantısı tanınmadı. Kaynak dosyaların uzantısı .fs, .fsi, .fsx veya .fsscript olmalıdır.</target>
<note />
</trans-unit>
<trans-unit id="chkDuplicatedMethodParameter">
<source>Duplicate parameter. The parameter '{0}' has been used more that once in this method.</source>
<target state="new">Duplicate parameter. The parameter '{0}' has been used more that once in this method.</target>
<note />
</trans-unit>
<trans-unit id="chkFeatureNotLanguageSupported">
<source>Feature '{0}' is not available in F# {1}. Please use language version {2} or greater.</source>
<target state="translated">'{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.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<target state="translated">无法识别“{0}”的文件扩展名。源文件必须具有扩展名 .fs、.fsi、.fsx 或 .fsscript</target>
<note />
</trans-unit>
<trans-unit id="chkDuplicatedMethodParameter">
<source>Duplicate parameter. The parameter '{0}' has been used more that once in this method.</source>
<target state="new">Duplicate parameter. The parameter '{0}' has been used more that once in this method.</target>
<note />
</trans-unit>
<trans-unit id="chkFeatureNotLanguageSupported">
<source>Feature '{0}' is not available in F# {1}. Please use language version {2} or greater.</source>
<target state="translated">功能“{0}”在 F# {1} 中不可用。请使用 {2} 或更高的语言版本。</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.zh-Hant.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<target state="translated">無法辨識 '{0}' 的副檔名。來源檔案的副檔名必須是 .fs、.fsi、.fsx 或 .fsscript。</target>
<note />
</trans-unit>
<trans-unit id="chkDuplicatedMethodParameter">
<source>Duplicate parameter. The parameter '{0}' has been used more that once in this method.</source>
<target state="new">Duplicate parameter. The parameter '{0}' has been used more that once in this method.</target>
<note />
</trans-unit>
<trans-unit id="chkFeatureNotLanguageSupported">
<source>Feature '{0}' is not available in F# {1}. Please use language version {2} or greater.</source>
<target state="translated">F# {1} 中無法使用 '{0}' 功能。請使用語言版本 {2} 或更新的版本。</target>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Loading