Skip to content
Merged
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
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/8.0.300.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### Fixed

* Fix a false positive of the `[<TailCall>]` analysis in combination with `yield!`. ([PR #16933](https://github.com/dotnet/fsharp/pull/16933))
* Improve error reporting: ambiguous override method in object expression. ([PR #16985](https://github.com/dotnet/fsharp/pull/16985))
* Don't blow the stack when traversing deeply nested sequential expressions. ([PR #16882](https://github.com/dotnet/fsharp/pull/16882))
* Fix wrong range start of INTERP_STRING_END. ([PR #16774](https://github.com/dotnet/fsharp/pull/16774), [PR #16785](https://github.com/dotnet/fsharp/pull/16785))
* Fix missing warning for recursive calls in list comprehensions. ([PR #16652](https://github.com/dotnet/fsharp/pull/16652))
Expand Down
6 changes: 3 additions & 3 deletions src/Compiler/Checking/MethodOverrides.fs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ module DispatchSlotChecking =
fail(Error(FSComp.SR.typrelMemberDoesNotHaveCorrectNumberOfTypeParameters(FormatOverride denv overrideBy, FormatMethInfoSig g amap m denv dispatchSlot), overrideBy.Range))
elif not (IsTyparKindMatch compiledSig overrideBy) then
fail(Error(FSComp.SR.typrelMemberDoesNotHaveCorrectKindsOfGenericParameters(FormatOverride denv overrideBy, FormatMethInfoSig g amap m denv dispatchSlot), overrideBy.Range))
else
else
fail(Error(FSComp.SR.typrelMemberCannotImplement(FormatOverride denv overrideBy, NicePrint.stringOfMethInfo infoReader m denv dispatchSlot, FormatMethInfoSig g amap m denv dispatchSlot), overrideBy.Range))
| overrideBy :: _ ->
errorR(Error(FSComp.SR.typrelOverloadNotFound(FormatMethInfoSig g amap m denv dispatchSlot, FormatMethInfoSig g amap m denv dispatchSlot), overrideBy.Range))
Expand All @@ -427,8 +427,8 @@ module DispatchSlotChecking =
else
// Error will be reported below in CheckOverridesAreAllUsedOnce
()
| _ ->
fail(Error(FSComp.SR.typrelOverrideWasAmbiguous(FormatMethInfoSig g amap m denv dispatchSlot), m))
| ambiguousOverride :: _ ->
fail(Error(FSComp.SR.typrelOverrideWasAmbiguous(FormatMethInfoSig g amap ambiguousOverride.Range denv dispatchSlot), ambiguousOverride.Range))
| _ -> fail(Error(FSComp.SR.typrelMoreThenOneOverride(FormatMethInfoSig g amap m denv dispatchSlot), m))

if missingOverloadImplementation.Count > 0 then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,32 @@ consoleLogger.Log("Hello World")
"""
|> withLangVersion80
|> compileExeAndRun
|> shouldSucceed
|> shouldSucceed

[<Fact>]
let ``Error reporting ambiguous override method in object expression`` () =
Fsx """
type IExample =
abstract member Overloaded : string -> bool
abstract member Overloaded : int -> bool

let failingExample x =
{ new IExample with
member __.Overloaded (_ : string) = x
member __.Overloaded (_ : int) = x }
"""
|> typecheck
|> shouldFail
|> withDiagnostics [
(Error 3213, Line 8, Col 19, Line 8, Col 29, "The member 'Overloaded: string -> 'a' matches multiple overloads of the same method.
Please restrict it to one of the following:
Overloaded: int -> bool
Overloaded: string -> bool.")
(Error 3213, Line 9, Col 19, Line 9, Col 29, "The member 'Overloaded: int -> 'a' matches multiple overloads of the same method.
Please restrict it to one of the following:
Overloaded: int -> bool
Overloaded: string -> bool.")
(Error 358, Line 8, Col 19, Line 8, Col 29, "The override for 'Overloaded: int -> bool' was ambiguous")
(Error 358, Line 8, Col 19, Line 8, Col 29, "The override for 'Overloaded: string -> bool' was ambiguous")
(Error 783, Line 7, Col 11, Line 7, Col 19, "At least one override did not correctly implement its corresponding abstract member")
]
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ type Test2 () =

CompilerAssert.CompileWithErrors(fsCmpl, [|
(FSharpDiagnosticSeverity.Error, 3350, (10, 15, 10, 22), "Feature 'default interface member consumption' is not available in F# 4.6. Please use language version " + targetVersion + " or greater.")
(FSharpDiagnosticSeverity.Error, 358, (10, 15, 10, 22), "The override for 'M<'U> : 'U * int -> unit' was ambiguous")
(FSharpDiagnosticSeverity.Error, 358, (14, 19, 14, 20), "The override for 'M<'U> : 'U * int -> unit' was ambiguous")
|])

#else
Expand Down