Skip to content

CFE: mismatch in how we treat -0 after constant-update #36562

@sigmundch

Description

@sigmundch

When enabling constant-update-2018, the following code:

const int x = 0;

const List<int> l = const [
  1,
  -x,
];

main() => print(l);

used to compile cleanly, but with the flag produces a compile time error:

bad_const.dart:5:3:
Error: Expected constant '-0.0' to be of type 'int', but was of type 'double'.
  -x,
  ^
bad_const.dart:8:17:
Info: While analyzing:
main() => print(l);
                ^
bad_const.dart:3:21:
Error: Constant expression depends on itself.
const List<int> l = const [
                    ^
bad_const.dart:3:17:
Info: While analyzing:
const List<int> l = const [
                ^
Error: Compilation failed.
Finished with a exit code: 1

@fishythefish can you take a first look - this unfortunately breaks existing code.

Metadata

Metadata

Assignees

Labels

P1A high priority bug; for example, a single project is unusable or has many test failurescustomer-dart2jslegacy-area-front-endLegacy: Use area-dart-model instead.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions