-
Notifications
You must be signed in to change notification settings - Fork 90
Description
The VM promotes a non-const value to const, dart2js does not.
$ diff pkg/vm/testcases/transformations/record_use/complex.dart.json.expect pkg/compiler/test/record_use/golden/complex.json.expect
3a4,7
> "type": "String",
> "value": "somestring"
> },
> {
25a39
> 0,
27,28c41
< null,
< 0
---
> 1The string argument is recorded as non-const in dart2js but as the string in the VM.
class OtherClass {
String string = 'somestring';
@RecordUse()
static Future<String> generate(
AssetBundle bundle,
List args,
String string,
AnotherClass object,
int index,
) async {
final message = await bundle.byIndex(string: string, index: index);
return message.generateString(args, object: object);
}
}This leads to inconsistencies between compilers.
We either need to
- restrict recording to only things from
constsources, or - accept differences between backends - based on best-effort.
If we go for (2), we need to specify what a backend at minimum needs to provide to be compliant.
Otherwise we risk someone testing with the VM compiler, thinking tree-shaking works, and inflating their web targets.
Also, if we go for (2), we need to be smarter about testing. We'd need some bool RecordedUses.containsAll(RecordedUses other) method so that we can use the minimum requirements to be compliant.
cc @goderbauer
Metadata
Metadata
Assignees
Labels
Type
Projects
Status