-
Notifications
You must be signed in to change notification settings - Fork 11
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
Compiler: Type checks not performed on super calls #3513
Comments
I'll just add the code examples from the vscode-as3mxml issue, so that the AIR SDK devs have more context without following the link to that issue. In this example, there should be a compile-time error because import flash.geom.Point;
class A
{
public function A(point:Point)
{
}
}
class B extends A
{
public function B()
{
super(42);
}
} And this example should have a similar compile-time error: override public function a(point:Point):void {
super.a(42);
} In the case of the AIR SDK compiler, I didn't specifically test whether other related checks are performed, but I'm guessing that they'll be missing similar to the Royale compiler, since they are related codebases. For example, it should also check that the number of arguments passed to the super method is correct. The Royale compiler didn't check that either. |
Thanks Josh! Although too late, I'd already followed the link :-) The linked issue is on the vscode-as3mxml project - I assume that's not actually the component at fault, and the fixes would need to come from us and from the Apache royale-compiler project? |
Correct. For royale-compiler, I've already implemented the necessary fixes in a branch. We have a release in progress, so they'll go into the next version. The commits with fixes, if you're interested, are linked below: apache/royale-compiler@f0444c6 |
I should also mention that making this change may introduce new compiler errors in existing AS3 code that previously compiled without errors. Users may need some guidance. In most cases, they just need to add a cast to convert to the correct type. In some cases, it may actually be a bug in their code that was previously undiscovered. I think that undiscovered bugs are a bit less common with the AIR SDK than with Royale because AIR has the verifier performing extra runtime checks that are more likely to catch issues and throw runtime exceptions for them. Royale runs in JS, which is untyped and more lenient, so Royale apps can pass bad types further away from their source, and are more likely to appear to be working correctly. Starling, Feathers, and other high-visibility projects shouldn't be affected because they're commonly compiled with both the AIR SDK and Flex SDK compilers, and the Flex SDK compiler doesn't have this bug. |
Having this would prevent runtime errors by detecting issues at compile time.
This issue was initially reported in BowlerHatLLC/vscode-as3mxml#770
Comment from @joshtynjala:
Please consider adding those type checks in a future version of the SDK.
Thanks
The text was updated successfully, but these errors were encountered: