Skip to content

Commit bfbc3e9

Browse files
committed
Suggest a function to implement
1 parent c1512fc commit bfbc3e9

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

src/fsharp/FSComp.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ tcExpressionWithIfRequiresParenthesis,"This list or array expression includes an
588588
764,tcFieldRequiresAssignment,"No assignment given for field '%s' of type '%s'"
589589
765,tcExtraneousFieldsGivenValues,"Extraneous fields have been given values"
590590
766,tcObjectExpressionsCanOnlyOverrideAbstractOrVirtual,"Only overrides of abstract and virtual members may be specified in object expressions"
591-
767,tcNoAbstractOrVirtualMemberFound,"The member '%s' does not correspond to any abstract or virtual method available to override or implement"
591+
767,tcNoAbstractOrVirtualMemberFound,"The member '%s' does not correspond to any abstract or virtual method available to override or implement.%s"
592592
768,tcArgumentArityMismatch,"The member '%s' does not accept the correct number of arguments, %d arguments are expected"
593593
769,tcArgumentArityMismatchOneOverload,"The member '%s' does not accept the correct number of arguments. One overload accepts %d arguments."
594594
770,tcSimpleMethodNameRequired,"A simple method name is required here"

src/fsharp/TypeChecker.fs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6209,7 +6209,13 @@ and FreshenObjExprAbstractSlot cenv (_env: TcEnv) implty virtNameAndArityPairs (
62096209
let absSlotsByName = List.filter (fst >> fst >> (=) bindName) virtNameAndArityPairs
62106210

62116211
match absSlotsByName with
6212-
| [] -> errorR(Error(FSComp.SR.tcNoAbstractOrVirtualMemberFound(bindName),mBinding))
6212+
| [] ->
6213+
let predictions =
6214+
virtNameAndArityPairs
6215+
|> List.map (fst >> fst)
6216+
|> ErrorResolutionHints.FilterPredictions bindName
6217+
6218+
errorR(Error(FSComp.SR.tcNoAbstractOrVirtualMemberFound(bindName, ErrorResolutionHints.FormatPredictions predictions),mBinding))
62136219
| [(_,absSlot:MethInfo)] -> errorR(Error(FSComp.SR.tcArgumentArityMismatch(bindName, (List.sum absSlot.NumArgs)),mBinding))
62146220
| (_,absSlot:MethInfo) :: _ -> errorR(Error(FSComp.SR.tcArgumentArityMismatchOneOverload(bindName, (List.sum absSlot.NumArgs)),mBinding))
62156221

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// #Warnings
2+
//<Expects status="Error" span="(11,14)" id="FS0767">The member 'Function' does not correspond to any abstract or virtual method available to override or implement.</Expects>
3+
//<Expects>MyFunction</Expects>
4+
5+
type IInterface =
6+
abstract MyFunction : int32 * int32 -> unit
7+
abstract SomeOtherFunction : int32 * int32 -> unit
8+
9+
let x =
10+
{ new IInterface with
11+
member this.Function (i, j) = ()
12+
}
13+
14+
exit 0

tests/fsharpqa/Source/Warnings/env.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
SOURCE=CommaInRecCtor.fs # CommaInRecCtor.fs
66
SOURCE=ValidCommaInRecCtor.fs # ValidCommaInRecCtor.fs
77
SOURCE=ElseBranchHasWrongType.fs # ElseBranchHasWrongType.fs
8+
SOURCE=NoMatchingAbstractMethodWithSameName.fs # NoMatchingAbstractMethodWithSameName.fs
89
SOURCE=MissingExpressionAfterLet.fs # MissingExpressionAfterLet.fs
910
SOURCE=AssignmentOnImmutable.fs # AssignmentOnImmutable.fs
1011
SOURCE=UpcastInsteadOfDowncast.fs # UpcastInsteadOfDowncast.fs

0 commit comments

Comments
 (0)