-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Optional new and const crash during compilation on Flutter 0.2.7-pre.6 #32737
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
Note from the doctor output that the SDK in the error report is build against 52afcba |
here's a much-cut-down example that still crashes: import 'package:flutter/material.dart';
void main() {}
class _MyHomePageState {
static Widget commentWidget(String comment) {
return Container(
child: Padding(
child: FittedBox(
fit: BoxFit.contain
),
),
);
}
}
|
@dgrove Looking at the cut-down example above (I can't find https://github.com/flutter/flutter_attract/tree/dart2), it looks like the problem is that |
/cc @Hixie re: previous comment |
Adding the import didn't change anything.
…On Mon, Apr 2, 2018 at 1:20 PM Brian Wilkerson ***@***.***> wrote:
@dgrove <https://github.com/dgrove> Looking at the cut-down example above
(I can't find https://github.com/flutter/flutter_attract/tree/dart2), it
looks like the problem is that BoxFit isn't defined. Could you try adding
an import of package:flutter/painting.dart and telling me whether you're
still seeing an error? (I'd try it myself, but I don't have a machine set
up with Flutter at this point.)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#32737 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACAsW8ob55jqIyC-e-p1RaLyJfG2dxTUks5tkogHgaJpZM4TD0hQ>
.
|
Ok. I managed to get set up enough to verify that BoxFit is exported from I don't know everything that's going on, but it appears that the exception is caused by handing the The second bug is that invalid code can presumably cause an exception. The |
Maybe it's because the constructor for |
I think this boils down to not yet handling constant fields:
Sorry, I haven't actually tested this locally. |
Thank you for the example, Peter. It is exactly the kind of yet unhandled expression kind that caused the issue. CL 49140 adds the support for static gets, and I was able to compile the example code without error with that. The compiler crash is another issue. It is because the evaluator didn't support nested expressions that require new/const insertion. So, if the inner expression with implicit new/const leads to a compile-time error, the generated invalid-expression node that signals about this compile-time error is then visited during new/const insertion for the outter expression. But, because invalid expressions aren't explicitly handled by the visitor, it leads to an invocation of |
CL 49508 adds the support for more expressions. More coming soon. |
@kmillikin @stefantsov Is there any work remaining here? |
This should be fixed. We will reopen if it recurs. |
Just had the same error. Here is the code.
After adding new keyword it compiled Flutter Doctor: Doctor summary (to see all details, run flutter doctor -v): • No issues found! |
Hi @AndreHaueisen -- thanks for building with Flutter! The fix hasn't made its way to the beta channel yet, but I've tested the code you wrote and it works perfectly without You can try for yourself by running |
Hi @timsneath |
@timsneath but i could have widgets without 'new' in beta 1 with dart 2 enabled.. but i cant do the same in beta 2 with dart 2 enabled...why? |
Hi @rajeshzmoke. That's due to churn as we (the Dart team) sorted out how this feature should work. In beta 1, we would infer We wanted to try to see if we could come up with a simple way to infer If all your widgets have We've settled on the original (beta 1) behavior for the time being, so all this churn was unnecessary and I apologize for it. |
My code is here:
https://github.com/flutter/flutter_attract/tree/dart2
(original code without optional new and const is in the master branch).
Crash:
Flutter doctor output:
The text was updated successfully, but these errors were encountered: