-
Notifications
You must be signed in to change notification settings - Fork 782
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
Better ranges for implicit inherit
error reporting.
#17893
base: main
Are you sure you want to change the base?
Better ranges for implicit inherit
error reporting.
#17893
Conversation
❗ Release notes required
|
Inherit
error reporting.inherit
error reporting.
Co-authored-by: Tomas Grosup <[email protected]>
…fgp/fsharp into better-ranges-for-implicit-Inherit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Edgar!
|> typecheck | ||
|> shouldFail | ||
|> withDiagnostics [ | ||
(Error 959, Line 10, Col 5, Line 10, Col 12, "Type definitions may only have one 'inherit' specification and it must be the first declaration") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually want both these errors? I mean 959 and 932 for each additional inherit
?
Is there ever a case where there's going to be a 932 without a corresponding 959? If not, is 932 actually useful?
And if we do want both, I'd argue 932 should be thrown only once regardless of how many extra inherit
specifications there are and its range should actually be line 8 in this example above, so like it was before:
type Class() =
^^^^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually want both these errors? I mean 959 and 932 for each additional inherit?
I guess arguably we do not need 959 as 932 will cover the cases for having multiple inherit
. Should we get ride of 959 ?
Personally I think showing the specific ranges for inherit is more clear and guides the user toward removing rather than just using the type definition.
Please wait for https://github.com/dotnet/fsharp/pull/17905/files to be merged first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marker to not merge this accidentally.
@edgarfgp Thanks for your contribution! I'm sorry to say this, but I disagree with this change. I'll try to explain it on this example: type T() =
inherit A()
inherit B() I expect that there's an error about multiple |
Could you please also add tests for multiple base interfaces, if there're none? type I =
inherit IA
inherit IB |
@auduchinok No need to apologise for disagreeing. This is a collaborative effort and Im glad that you are reviewing my PRs :) So is the following what you would expect ? [<Fact>]
let ``Types cannot inherit from multiple concrete types.`` () =
Fsx """
type ClassA() = class end
type ClassB() = class end
type ClassC() = class end
type Class() =
inherit ClassA()
inherit ClassB()
inherit ClassC()
"""
|> typecheck
|> shouldFail
|> withDiagnostics [
(Error 959, Line 10, Col 5, Line 10, Col 12, "Type definitions may only have one 'inherit' specification and it must be the first declaration")
(Error 959, Line 11, Col 5, Line 11, Col 12, "Type definitions may only have one 'inherit' specification and it must be the first declaration")
(Error 932, Line 10, Col 13, Line 10, Col 19, "Types cannot inherit from multiple concrete types")
(Error 932, Line 11, Col 13, Line 11, Col 19, "Types cannot inherit from multiple concrete types")
] |
@edgarfgp More or less, yes. I'd probably prefer the |
Humm. But using the type name and not the |
Hm, it should not, since |
Description
Better ranges for implicit Inherit error reporting.
Before
After
Checklist