-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[CFE] Missing override error => soundness issue in vm #46389
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
Comments
The CFE inserts a concrete forwarding stub, which is currently replaced by a clone of the abstract Either we shouldn't allow this in the first place - for that we need a clear(er) guide for when (not) to insert concrete forwarding stubs - or we should add the needed check to the passed argument in the concrete forwarding stub. That is, generate this concrete forwarding stub: num foo(covariant num x) => super.foo(x as int); instead of the current num foo(covariant num x) => super.foo(x); |
We discussed whether the situation is specified. I believe it is actually covered by the current language specification:
Note that the parameter it is not marked We would then get an error because The most tricky part here is probably that the member signature of the inherited implementation may or may not include the class A { num foo(num n) => 1.1; }
abstract class B { num foo(covariant num x); }
class C extends A with B {} // Error The error arises here because the interface of If we had written We don't specify exactly in which situations a class must have an implicitly induced forwarding method (with or without a dynamic type check on some parameters), it is up to each implementation to ensure that the resulting program behavior is sound, and this could be achieved by adding such forwarding methods when necessary, but there could also be other compilation strategies (e.g., adding a parameter type check to the body of |
Thinking about this some more, I do think we need to add a paragraph to the language specification about the error that is caused by a missing |
Consider the following program:
This program is rejected by the analyzer, as it should be:
However, the CFE does not detect this override error. With
dart
, it generates code whereA.foo
isn't overridden, andA.foo
does not check the type of the actual argument, so we reachprint(n.runtimeType)
and it prints 'double', which is a soundness violation.Note that this isn't exclusively a matter for the CFE:
dart2js
does perform the type check at the invocation offoo
, so it does throw.The text was updated successfully, but these errors were encountered: