Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 34 - check for duplicate extension members #443

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
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"