-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Misleading error for abstract method return type #9460
Comments
Just a note that the error has nothing to do with subclasses. Here's the smallest snippet that reproduces this: abstract class Foo
abstract def foo : Int32
end
class Bar < Foo
def foo : Int32
false
end
end
Bar.new.foo The bug is that the abstract def checking produces a warning, but the warning is only shown on the codegen phase (why???). But before reaching that the semantic error already triggers where the return type doesn't match the type of the body. The solution is to report the warning as soon as it is detected, as it was in the past, before warnings were refactored and moved to the codegen phase. Thank you. |
This snippet reproduces the faulty compiler behaviour. But from the user perspective it doesn't matter because it still points you to the location with an appropriate error message. |
There's something that's not clear here that I just found out: warnings are not shown if there are compiler errors. In my opinion that's plain wrong. |
Oh, well, I guess the first snippet is the one that makes sense. But to fix it, if warnings were reported in addition to errors you would immediately know what the problem is. I have a fix. But then, I also think "abstract method" warnings should be errors... except that the logic to implement that is very hard so we might not be able to do that before 1.0. |
This is extracted from #9454.
Since the changes in 0.35.0 to the return type of
IO#write
, lot's of errors like this pop up:The problem is that the indicated location is not where the error is. The method
IO::Hexdump#write
just happens to call#write
on the wrapped io. And when there's anIO
subtype where#write
doesn't have a type restriction, that type causes an error here.But instead, the error should be reported at the original location where the type restriction is missing.
Isolated example:
Adding
Int64
type restriction toBaz#write
fixes the issue. Then the compiler error correctly points toBaz#write
as the offender.The text was updated successfully, but these errors were encountered: