-
-
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
False positive positional parameter mismatch warning #12150
Comments
I will probably add a check where if any one of the overloads implements the abstract def completely, then no warnings would be generated for any other overloads. This requires that all the parameters are identical and that all the restrictions are contravariant (less strict than the corresponding ones in the abstract def): abstract class Foo
abstract def foo(x : Int, y : Int)
end
class Bar1 < Foo
def foo(x : Int, y : Int); end
def foo(x : Int, z : Int, *xs); end # okay, no warnings
end
class Bar2 < Foo
def foo(x : Int, y : Int, *xs); end
def foo(x : Number, z : Int, *xs); end # warns, because first overload has different parameters
end
class Bar3 < Foo
def foo(x : Int32, y : Int32); end
def foo(x : Int, z : Int); end # warns, because first overload is not contravariant
end
class Bar4 < Foo
def foo(x : Int, y : Int); end
def foo(x : Int, z : Int); end # warns, because this overload redefines the first one
end Otherwise, one has to determine whether an abstract def has been exhausted by previous overloads in a class: abstract class Foo
abstract def foo(x : Int32 | String)
end
class Bar < Foo
def foo(x : Int32); end
def foo(x : String); end
# need to show that the above overloads exhaust the abstract def
# (at this point overloads are already ordered by strictness)
def foo(y); end
end which amounts to solving #8232. |
The same can also be said about return type checks: #11915 (comment) |
Bug Report
While working on updating Athena to fix the warnings from #11915, I came across an unexpected warning:
results in:
I would have expected this to not produce a warning since its own overload and not part of the interface at all.
The text was updated successfully, but these errors were encountered: