-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.legacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.
Description
Consider the following code, adapted from the repro for #36511:
enum Foo {
bar,
baz
}
main() {
const x = Foo.bar == Foo.baz;
print(x);
}This code is erroneous, because Foo.bar == Foo.baz is not a valid constant expression. Equality checks in constant expressions may only be used to compare primitive types; they may not be used to compare user-provided types such as Foo.
The analyzer correctly detects the error, reporting:
error • In constant expressions, operands of this operator must be of type 'bool', 'num', 'String' or 'null' at .../test.dart:6:13 • const_eval_type_bool_num_string
But the VM executes the code without complaint.
(I'm classifying this bug as both area-vm and area-front-end because I'm not sure whether the VM has been transitioned over to using the front end's constant evaluator yet. Feel free to reassign as appropriate.)
Metadata
Metadata
Assignees
Labels
area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.legacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.