Bug Report
The AbstractDefChecker visitor needs to resolve types to verify if the implementation is compatible with the abstract def. Currently, it is too lax for arguments and too strict for the return type.
Example 1: (compiles, but shouldn't)
module Foo
abstract def foo(x : Unknown)
end
class Bar
include Foo
def foo(x : Int32)
end
end
If the argument type can't be resolved (on either side) it is just ignored. The compiler should fail if it can't validate the argument properly.
Example 2: (doesn't compile, but should)
module Foo
abstract def foo(x : U) : U forall U
end
class Bar
include Foo
def foo(x : U) : U forall U
x
end
end
In test.cr:2:29
17 | abstract def foo(x : U) : U forall U
^
Error: can't resolve return type U
Here it tries to resolve U to a concrete type, but it fails because it is just a Path.
The first problem is easy to solve, we can just remove a begin..rescue at Crystal::AbstractDefChecker#check_arg. But then it will be very strict (like example 2) everywhere and this will basically break forall defs. The second problem must be solved first.
Here we need to find a way to check the types without fully resolving them.
I tested this with Crystal 1.0.0 and the current master.
Bug Report
The AbstractDefChecker visitor needs to resolve types to verify if the implementation is compatible with the abstract def. Currently, it is too lax for arguments and too strict for the return type.
Example 1: (compiles, but shouldn't)
If the argument type can't be resolved (on either side) it is just ignored. The compiler should fail if it can't validate the argument properly.
Example 2: (doesn't compile, but should)
Here it tries to resolve
Uto a concrete type, but it fails because it is just aPath.The first problem is easy to solve, we can just remove a
begin..rescueatCrystal::AbstractDefChecker#check_arg. But then it will be very strict (like example 2) everywhere and this will basically breakforalldefs. The second problem must be solved first.Here we need to find a way to check the types without fully resolving them.
I tested this with Crystal 1.0.0 and the current master.