-
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
dart2js crash (go_router problem?): Operand of null-aware operation '!' has type 'String' which excludes null #53291
Comments
After some trying I found, if you add into new flutter project:
then
|
It looks like this error occurs when the CFE attempts to serialize the AST. |
Seems that the issue is coming up when trying to serialize the consturctor-tearoff of a static interop class that has a generic parameter. In the code above it is caused by the Here is a standalone repro with no external dependencies using import 'dart:js_interop';
@anonymous
@JS('Iterator')
@staticInterop
class JsIterator<T> {
external factory JsIterator();
}
main() {} Then running
Removing the type parameter indeed circumvents this crash (note that being an external class, the type parameter has no purpose so it is safe to be removed and to keep it only in the static extension). That said, we should make the tool chain more robust to ensure it doesn't crash on cases like these. |
cc @srujzs A few things to highlight:
|
Yes, but this only applies to @staticInterop classes and not other package:js classes. |
I'll take a look. |
The problem is in sdk/pkg/_js_interop_checks/lib/src/transformations/static_interop_class_eraser.dart Line 327 in 640c72d
The node.target.function.returnType is not the JavaScriptObject type as intended given the comment in sdk/pkg/_js_interop_checks/lib/src/transformations/static_interop_class_eraser.dart Line 324 in 640c72d
|
Thank so much @johnniwinther for your help investigating here! |
I think we want to rather erase that type in the cast, which we aren't doing now, which fixes this issue. The generic tear-off's return type will be erased, so it makes sense to align it there. |
@srujzs - Given that the issue produces a crash that potentially multiple users have encountered, and that the fix is pretty contained and low risk, we should consider filing a cherry-pick for including it in the stable channel |
Yeah, I think working around this issue is a bit of a pain per my comment on the related issue, so a cherry-pick makes sense. I'll go ahead and file one. |
What didn't work:
flutter build web
Happens both times: with local build, and in github action (https://github.com/Alexqwesa/ais3uson_app/actions/runs/5918034312/job/16046960775)
What works:
Output of
flutter build web
:flutter doctor --verbose
The text was updated successfully, but these errors were encountered: