You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just pass the following piece of code to any Nit engine and see it crash:
class A
type X: Numeric
fun foo: X do return 42
end
class B
super A
redef type X: Int
end
class C
super A
redef type X: Float
end
class D
super B
super C
end
var y = new D
print y.foo
@egagnon: So, we can not refer to this case while discussing about virtual types support for now. 😄
The text was updated successfully, but these errors were encountered:
jcbrinfo
changed the title
Nit crashes in case of virtual type conflicts
Crash in case of virtual type conflicts
Sep 26, 2016
Virtual types checks are not that nice in fact. The crash here is explicit by an abort since the conflict is detected. What is missing is 1. how to present the; 2. how to return the chain of methods and gracefully try to continue.
This is hard to do because the detection is quite deep in the semantic analysis.
In order to solve the bug I need to think what is the best error message to present to the programmer.
Is the bug in class D ? is the bug in y.foo ?
One way we can deal with this case for now is to force the developer to redefine X in D (in this particular example, no definition of D::X will be accepted in practice). However, if one day, we implement intersection types (which would solve a lot of problems for what I’m working on), we would be able to implicitly define D::X as the intersection of Int and Float and the error would be caught by the implicitly cast on the return value of foo.
Just pass the following piece of code to any Nit engine and see it crash:
@egagnon: So, we can not refer to this case while discussing about virtual types support for now. 😄
The text was updated successfully, but these errors were encountered: