dart2js: stable order for compile time constant initializations #10989
Labels
area-web
Issues related to Dart Web.
P2
A bug or feature request we're likely to work on
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
web-dart2js
Compile time structured constant initializers are topo-sorted, but from an initially unstable set.
Minor perturbations of the source cause the constants block to be shuffled.
It is not clear what the 'source order' is since e.g. 'const Duration(0)' can occur in many places.
Option 1.
Maintain a map / field of the earliest source location, updated when the AST is resolved to a constant.
Option 2.
Since the naming of the constants is now stable, it would not be unreasonable to sort by JavaScript name before topo-sort. Not all constants have a name (e.g. numbers and top static functions), so the constants would be split into named and unnamed lists, sort the named, then append the two lists.
Minified names are rather arbitrary - sorting by the name of the constructor and then the constant name will cluster the 'new' expressions and likely improve gzip compression.
The text was updated successfully, but these errors were encountered: