Skip to content

Commit

Permalink
Fix 34 - extension member duplicate check
Browse files Browse the repository at this point in the history
fixes #34
closes #443

commit 4f6c739
Author: Don Syme <donsyme@fastmail.fm>
Date:   Tue May 12 17:38:00 2015 +0100

    Fix 34 - extension member duplicate check (5)

commit 17b1cdb
Author: Don Syme <donsyme@fastmail.fm>
Date:   Tue May 12 17:37:19 2015 +0100

    Fix 34 - extension member duplicate check (4)

commit e9bfa81
Author: Don Syme <donsyme@fastmail.fm>
Date:   Tue May 12 17:35:46 2015 +0100

    Fix 34 - extension member duplicate check (3)

commit 8d85332
Author: Don Syme <donsyme@fastmail.fm>
Date:   Tue May 12 17:25:32 2015 +0100

    Fix 34 - extension member duplicate check (2)
  • Loading branch information
dsyme authored and latkin committed May 19, 2015
1 parent b1464a7 commit 34a181b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/fsharp/check.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,18 @@ let CheckTopBinding cenv env (TBind(v,e,_) as bind) =
check false v.DisplayName
check false v.CompiledName

// Check if an F# extension member clashes
if v.IsExtensionMember then
tcref.ModuleOrNamespaceType.AllValsAndMembersByLogicalNameUncached.[v.LogicalName] |> List.iter (fun v2 ->
if v2.IsExtensionMember && not (valEq v v2) && v.CompiledName = v2.CompiledName then
let minfo1 = FSMeth(cenv.g, generalizedTyconRef tcref, mkLocalValRef v, Some 0UL)
let minfo2 = FSMeth(cenv.g, generalizedTyconRef tcref, mkLocalValRef v2, Some 0UL)
if tyconRefEq cenv.g v.MemberApparentParent v2.MemberApparentParent &&
MethInfosEquivByNameAndSig EraseAll true cenv.g cenv.amap v.Range minfo1 minfo2 then
errorR(Duplicate(kind,v.DisplayName,v.Range)))



// Properties get 'get_X', only if there are no args
// Properties get 'get_X'
match v.ValReprInfo with
Expand Down
8 changes: 8 additions & 0 deletions tests/fsharp/typecheck/sigs/neg23.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@ neg23.fs(92,18,92,21): typecheck error FS0439: The method 'X04' has curried argu
neg23.fs(110,21,110,22): typecheck error FS0439: The method 'F' has curried arguments but has the same name as another method in this type. Methods with curried arguments cannot be overloaded. Consider using a method taking tupled arguments.

neg23.fs(113,21,113,22): typecheck error FS0439: The method 'F' has curried arguments but has the same name as another method in this type. Methods with curried arguments cannot be overloaded. Consider using a method taking tupled arguments.

neg23.fs(164,18,164,29): typecheck error FS0037: Two members called 'GroupRowsBy' have the same signature

neg23.fs(165,18,165,29): typecheck error FS0037: Two members called 'GroupRowsBy' have the same signature

neg23.fs(168,17,168,20): typecheck error FS0037: Two members called 'Foo' have the same signature

neg23.fs(169,17,169,20): typecheck error FS0037: Two members called 'Foo' have the same signature
12 changes: 12 additions & 0 deletions tests/fsharp/typecheck/sigs/neg23.fs
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,15 @@ module PositiveTests =
let y2 : int -> int = c.M2 (3,4)
let y3 : int * int -> int -> int = c.M2


type Frame =
class
end
module X =
type Frame with
member frame.GroupRowsBy(key) = ()
member frame.GroupRowsBy(key) = ()

// Up to erasure
member this.Foo (x:int->int) = printfn "method 1"
member this.Foo (x:FSharpFunc<int,int>) = printfn "method 2"

0 comments on commit 34a181b

Please sign in to comment.