@@ -396,7 +396,22 @@ let CheckDuplicates (idf: _ -> Ident) k elems =
396396 errorR ( Duplicate( k, id1.idText, id1.idRange))))
397397 elems
398398
399-
399+ let private CheckDuplicatesArgNames ( synVal : SynValSig ) m =
400+ let argNames = synVal.SynInfo.ArgNames |> List.duplicates
401+ for name in argNames do
402+ errorR( Error(( FSComp.SR.chkDuplicatedMethodParameter( name), m)))
403+
404+ let private CheckDuplicatesAbstractMethodParmsSig ( typeSpecs : SynTypeDefnSig list ) =
405+ for SynTypeDefnSig( typeRepr= trepr) in typeSpecs do
406+ match trepr with
407+ | SynTypeDefnSigRepr.ObjectModel(_, synMemberSigs, _) ->
408+ for sms in synMemberSigs do
409+ match sms with
410+ | SynMemberSig.Member( synValSig, _, m) ->
411+ CheckDuplicatesArgNames synValSig m
412+ | _ -> ()
413+ | _ -> ()
414+
400415module TcRecdUnionAndEnumDeclarations =
401416
402417 let CombineReprAccess parent vis =
@@ -438,13 +453,13 @@ module TcRecdUnionAndEnumDeclarations =
438453 | _ -> ()
439454 rfspec
440455
441- let TcAnonFieldDecl cenv env parent tpenv nm ( SynField ( Attributes attribs , isStatic , idOpt , ty , isMutable , xmldoc , vis , m )) =
456+ let TcAnonFieldDecl cenv env parent tpenv nm ( SynField ( Attributes attribs , isStatic , idOpt , ty , isMutable , xmldoc , vis , m , _ )) =
442457 let mName = m.MakeSynthetic()
443458 let id = match idOpt with None -> mkSynId mName nm | Some id -> id
444459 let xmlDoc = xmldoc.ToXmlDoc( true , Some [])
445460 TcFieldDecl cenv env parent false tpenv ( isStatic, attribs, id, idOpt.IsNone, ty, isMutable, xmlDoc, vis, m)
446461
447- let TcNamedFieldDecl cenv env parent isIncrClass tpenv ( SynField ( Attributes attribs , isStatic , id , ty , isMutable , xmldoc , vis , m )) =
462+ let TcNamedFieldDecl cenv env parent isIncrClass tpenv ( SynField ( Attributes attribs , isStatic , id , ty , isMutable , xmldoc , vis , m , _ )) =
448463 match id with
449464 | None -> error ( Error( FSComp.SR.tcFieldRequiresName(), m))
450465 | Some id ->
@@ -480,10 +495,10 @@ module TcRecdUnionAndEnumDeclarations =
480495 match seen.TryGetValue f.LogicalName with
481496 | true , synField ->
482497 match sf, synField with
483- | SynField(_, _, Some id, _, _, _, _, _ ), SynField(_, _, Some _, _, _, _, _, _) ->
498+ | SynField( idOpt = Some id), SynField( idOpt = Some _) ->
484499 error( Error( FSComp.SR.tcFieldNameIsUsedModeThanOnce( id.idText), id.idRange))
485- | SynField(_, _, Some id, _, _, _, _, _ ), SynField(_, _, None, _, _, _, _, _ )
486- | SynField(_, _, None, _, _, _, _, _ ), SynField(_, _, Some id, _, _, _, _, _ ) ->
500+ | SynField( idOpt = Some id), SynField( idOpt = None)
501+ | SynField( idOpt = None), SynField( idOpt = Some id) ->
487502 error( Error( FSComp.SR.tcFieldNameConflictsWithGeneratedNameForAnonymousField( id.idText), id.idRange))
488503 | _ -> assert false
489504 | _ ->
@@ -2363,7 +2378,7 @@ module EstablishTypeDefinitionCores =
23632378 for SynUnionCase ( caseType= args; range= m) in unionCases do
23642379 match args with
23652380 | SynUnionCaseKind.Fields flds ->
2366- for SynField(_, _, _, ty , _, _, _, m) in flds do
2381+ for SynField( fieldType = ty ; range = m) in flds do
23672382 let tyR , _ = TcTypeAndRecover cenv NoNewTypars NoCheckCxs ItemOccurence.UseInType WarnOnIWSAM.Yes env tpenv ty
23682383 yield ( tyR, m)
23692384
@@ -2380,7 +2395,7 @@ module EstablishTypeDefinitionCores =
23802395
23812396 | SynTypeDefnSimpleRepr.General (_, _, _, fields, _, _, implicitCtorSynPats, _) when tycon.IsFSharpStructOrEnumTycon -> // for structs
23822397 for field in fields do
2383- let ( SynField ( _ , isStatic , _ , ty , _ , _ , _ , m )) = field
2398+ let ( SynField ( isStatic = isStatic; fieldType = ty ; range = m)) = field
23842399 if not isStatic then
23852400 let tyR , _ = TcTypeAndRecover cenv NoNewTypars NoCheckCxs ItemOccurence.UseInType WarnOnIWSAM.Yes env tpenv ty
23862401 yield ( tyR, m)
@@ -2400,7 +2415,7 @@ module EstablishTypeDefinitionCores =
24002415 yield ( ty, m)
24012416
24022417 | SynTypeDefnSimpleRepr.Record (_, fields, _) ->
2403- for SynField(_, _, _, ty , _, _, _, m) in fields do
2418+ for SynField( fieldType = ty ; range = m) in fields do
24042419 let tyR , _ = TcTypeAndRecover cenv NoNewTypars NoCheckCxs ItemOccurence.UseInType WarnOnIWSAM.Yes env tpenv ty
24052420 yield ( tyR, m)
24062421
@@ -3947,6 +3962,14 @@ module TcDeclarations =
39473962 | SynMemberDefn.NestedType ( range= m) :: _ -> errorR( Error( FSComp.SR.tcTypesCannotContainNestedTypes(), m))
39483963 | _ -> ()
39493964 | ds ->
3965+ // Check for duplicated parameters in abstract methods
3966+ for slot in ds do
3967+ if isAbstractSlot slot then
3968+ match slot with
3969+ | SynMemberDefn.AbstractSlot ( synVal, _, m) ->
3970+ CheckDuplicatesArgNames synVal m
3971+ | _ -> ()
3972+
39503973 // Classic class construction
39513974 let _ , ds = List.takeUntil ( allFalse [ isMember; isAbstractSlot; isInterface; isInherit; isField; isTycon]) ds
39523975 match ds with
@@ -3976,7 +3999,7 @@ module TcDeclarations =
39763999 | SynTypeDefnRepr.ObjectModel( kind, cspec, m) ->
39774000 let cspec = desugarGetSetMembers cspec
39784001 CheckMembersForm cspec
3979- let fields = cspec |> List.choose ( function SynMemberDefn.ValField ( f , _ ) -> Some f | _ -> None)
4002+ let fields = cspec |> List.choose ( function SynMemberDefn.ValField ( fieldInfo = f ) -> Some f | _ -> None)
39804003 let implements2 = cspec |> List.choose ( function SynMemberDefn.Interface ( interfaceType= ty) -> Some( ty, ty.Range) | _ -> None)
39814004 let inherits =
39824005 cspec |> List.choose ( function
@@ -4034,7 +4057,7 @@ module TcDeclarations =
40344057 // Convert auto properties to member bindings in the post-list
40354058 let rec postAutoProps memb =
40364059 match memb with
4037- | SynMemberDefn.AutoProperty( attributes= Attributes attribs; isStatic= isStatic; ident= id; typeOpt= tyOpt; propKind= propKind; memberFlags= memberFlags; memberFlagsForSet= memberFlagsForSet; xmlDoc= xmlDoc; accessibility= access; getSetRange = mGetSetOpt) ->
4060+ | SynMemberDefn.AutoProperty( attributes= Attributes attribs; isStatic= isStatic; ident= id; typeOpt= tyOpt; propKind= propKind; memberFlags= memberFlags; memberFlagsForSet= memberFlagsForSet; xmlDoc= xmlDoc; accessibility= access; trivia = { GetSetKeyword = mGetSetOpt } ) ->
40384061 let mMemberPortion = id.idRange
40394062 // Only the keep the non-field-targeted attributes
40404063 let attribs = attribs |> List.filter ( fun a -> match a.Target with Some t when t.idText = " field" -> false | _ -> true )
@@ -4352,7 +4375,8 @@ let rec TcSignatureElementNonMutRec (cenv: cenv) parent typeNames endm (env: TcE
43524375 let _ , _ , _ , env = TcExceptionDeclarations.TcExnSignature cenv env parent emptyUnscopedTyparEnv ( edef, scopem)
43534376 return env
43544377
4355- | SynModuleSigDecl.Types ( typeSpecs, m) ->
4378+ | SynModuleSigDecl.Types ( typeSpecs, m) ->
4379+ CheckDuplicatesAbstractMethodParmsSig typeSpecs
43564380 let scopem = unionRanges m endm
43574381 let mutRecDefns = typeSpecs |> List.map MutRecShape.Tycon
43584382 let env = TcDeclarations.TcMutRecSignatureDecls cenv env parent typeNames emptyUnscopedTyparEnv m scopem None mutRecDefns
@@ -4522,7 +4546,8 @@ and TcSignatureElementsMutRec cenv parent typeNames m mutRecNSInfo envInitial (d
45224546 let rec loop isNamespace moduleRange defs : MutRecSigsInitialData =
45234547 (( true , true ), defs) ||> List.collectFold ( fun ( openOk , moduleAbbrevOk ) def ->
45244548 match def with
4525- | SynModuleSigDecl.Types ( typeSpecs, _) ->
4549+ | SynModuleSigDecl.Types ( typeSpecs, _) ->
4550+ CheckDuplicatesAbstractMethodParmsSig typeSpecs
45264551 let decls = typeSpecs |> List.map MutRecShape.Tycon
45274552 decls, ( false , false )
45284553
0 commit comments