-
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
SEVERE: dartdevc
can't compile closure/local function returning FutureOr<T?>
#48631
Comments
dartdevc
can't compile closure/local function returning FutureOr<T?>dartdevc
can't compile closure/local function returning FutureOr<T?>
dartdevc
can't compile closure/local function returning FutureOr<T?>dartdevc
can't compile closure/local function returning FutureOr<T?>
Line throwing the error: |
FYI: @nshahan |
@gmpassos Thanks for the minimal reproduction, it really helps us resolve these bugs! @johnniwinther @chloestefantsova This looks like another case of the undetermined nullability leaking through to the DDC backend. The text dump of the .dill file shows undetermined nullability coming through in a few places. The crash is specifically coming from the the return type of the local method
|
If you need some help to test some fix, just let me know. The actual error happened in a much bigger code, and a complex method. I spent 2h to isolate the bug, since the Actually I had to clone the Dart SDK, and change de internal I strongly recommend to add some context to the exceptions of the compiler. At least the file, class and method. Since even the reported file not generated by the compiler was totally different from the file containing the error. |
Another thing. I think that the package https://pub.dev/packages/dev_compiler It's 5 years old! |
@kevmoo Do you have any thoughts on archiving/unlisting the dev_compiler package? It was last published before my time but I'm not aware of any need for it on pub. |
- `EntityHandler.resolveValueByType`: - Avoid `dev_compiler` bug dart-lang/sdk#48631 when generating JS code.
@gmpassos the package is flagged Not that anyone can install this with a modern Dart SDK, when it has an SDK constraint of |
I encountered the exact same exception, but didn't take the time to isolate the code-block that caused it. Kudos to @gmpassos that you figured that out. I just continued using iOS/Android for debugging purposes. But of course, I would also be happy if debugging on the web works again for me, so now that this ticket is closed, I wondered if my exception was also gone - so I updated to the master channel in which the fix should already be applied;
But I still encounter the same exception:
Now, the question is; And I would really like to support the suggestion of @gmpassos:
Because it would be quite a task for me to find the cause of this error. Funnily, in my full code, I don't even have "FutureOr" used - so I suspect a package, but as I use 60 packages I can't really point my finger in any direction. Of course, maybe at some point I will be forced to go through this in any case - in the meantime I can still use the release-version for web-testing - as this error is "only" in the debug version. Anyway, thank you all for the time spent on solving flutter problems, it is really fun to work with :-) |
Can you test the code at?: https://github.com/gmpassos/dev_compiler_test With the last Dart at dev channel? This fix entered in version 2.17.0-258.0.dev |
I see the fix is first present in 2.17.0-247.0.dev according to the list of tags shown here
I totally agree that we need the error message to provide more context to be helpful in tracking down these bugs. The trickiest part is that when the invalid state is recognized, we don't have any source location information. We have been discussing how we can add enough context to be helpful without having to touch every visitor in the compiler. I think I can pretty easily include the name of the library and at least that could help us narrow it down among many packages. |
Note: the dev compiler compiles all the imported packages and related Dart files (there's no tree shaking). This is why a separated package (not your own code) can trigger any dev compiler bug. When the bug happened with my project I had a lot of work to identify which package and method was triggering the bug, and it was in a 3rd part package (in a file that wasn't being used by my project, even indirectly, but was part of the exported files of the package). |
I'm landing a quick fix that should help at least narrow down the library and the type that contains the undetermined nullability https://dart-review.googlesource.com/c/sdk/+/239722. To get more source location information we will need to follow up with a larger change. |
I'm working an experiment to restrict the use of |
I tried the original reproduction from the top of this thread with your new change and did not see any regressions. I don't yet have a repro for the issue that @perret123 ran into so I'm not sure about that one. |
Thank you for the quick fixes @nshahan @chloestefantsova The issue was caused by my code after all - in combination with the riverpod 1.0.3 package. As the riverpod code is quite complex, I only made a reproducible example with usage of the riverpod package and flutter. Is this already helpful for you? If not, feel free to tell me.
Running this example with Flutter 2.13.0-0.0.pre.362 with Dart 2.17.0-263.0.dev on Chrome gives the following output:
The newly added output of the file/type is very helpful in finding the cause of the exception, thank you! |
I made a repro. import 'dart:async';
abstract class A {
T foo<T>(B<T> b);
}
class B<X> {
B(X x);
}
class C<Y> {
final Bar<FutureOr<Y>, D<Y>> bar;
C(this.bar);
}
abstract class D<W> implements A {}
typedef Bar<V, U extends A> = V Function(U);
final baz = C<int>((a) {
return a.foo(B(Future.value(0)));
}); When compiled to Kernel by the CFE it emits the following code with a suspicious
That type does seem suspicious, so I'll work on eliminating that (it should be just |
I just landed the CL https://dart-review.googlesource.com/c/sdk/+/240049 that should fix that particular second case of undetermined nullability. I'm currently working on a bigger change that should work for similar cases arising in future. |
Bug: #48631 Change-Id: I329a70386d59425cf3f157dc4b6316649f8aa389 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240049 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Bug: #48631 Change-Id: I329a70386d59425cf3f157dc4b6316649f8aa389 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240049 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Has this bug been fixed? |
Yes, I believe the issue can be closed. Feel free to reopen if needed. |
I have isolated the bug with code examples to reproduce it at:
https://github.com/gmpassos/dev_compiler_test
The error happens with
Dart 2.16.1
(current stable) and alsoDart 2.17.0-182.1.beta
(current beta). Today is 2022/03/21.Specific code that triggers the compiler error:
https://github.com/gmpassos/dev_compiler_test/blob/master/example/example_error.dart
Error:
The text was updated successfully, but these errors were encountered: