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
Analyzer: Evaluation of constant expression using multiple libraries throws an exception #38658
Comments
EDIT: This is a divergence between the analyzer and the compiler that happens on Dart 2.6 and (in rare cases?) on Dart 2.5. See minimal repro that doesn't depend on anything but Some more information on this: Here is the const constructor being called. All of entries in the list literal are simple constant constructors defined in this file. I might be overlooking something, but I believe that this is an issue in the analyzer because
Some users (me included) hit this issue, but I never managed to consistently reproduce it - the error always went away after restarting the analysis server or typing in the affected file. @rebaz94 said that restarting the analysis server did not fix the problem. We discussed this problem in simolus3/drift#154 |
I get the same analysis error on All the tests (which definitely run that line) pass though, so the analyzer rejects it but the frontend doesn't? |
Smallest repro I could find: Create two Dart files, // base.dart
class Base<T> {
const Base();
}
class A extends Base<String> {
const A();
}
class Repro {
final List<Base> bases;
const Repro(this.bases);
const Repro.foo() : this(const [A()]);
}
and // repro.dart
import 'base.dart';
void main() {
const Repro.foo(); // "evaluation of this constant expression throws exception"
} Notably, the error does not occur when Edit I've fixed the typo. Possibly related to #38659? |
Probably: void main() {
const Repro.foo();
} That causes the error with an analyzer from commit 0242dea, and there's no error when the two libraries are combined into one library. |
In my case the error was that the package had an assert preventing null and because the value was optional in the child class parameter list, it threw the non-descript error message. At runtime on web it threw an error without a message and on ios/android it throws the proper assert message. |
I think this is solved because I can no longer reproduce it. Please re-open if you hit this on a recent version of Dart. |
There is an issue in the analysis server that said
the code that produces is
@simolus3
The text was updated successfully, but these errors were encountered: