-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
feature-null-aware-elementsImplementation of the Null-aware elements featureImplementation of the Null-aware elements featurelegacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.model-featuresGeneral feature work in the analyzer and CFE.General feature work in the analyzer and CFE.soundnesstype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
Description
https://github.com/dart-lang/co19/blob/master/LanguageFeatures/Control-flow-collections/Null-aware-elements/runtime_A02_t02.dart fails at run time on VM, dart2js and dart2wasm.
String _log = "";
int? f(int? v) {
_log += "f($v);";
return v;
}
main() {
var map1 = {
f(1): ?f(2),
?f(3): ?f(null),
?f(4): ?null
};
Expect.mapEquals({1: 2}, map1);
Expect.equals("f(1);f(2);f(3);f(null);f(4);", _log); // Expect.equals(expected: <f(1);f(2);f(3);f(null);f(4);>, actual: <f(2);f(1);f(3);f(null);f(4);>) fails.
...
}
Why map value is evaluated before the key? According to the spec the key should be evaluated first.
Else, if element is a nullAwareMapElement with entry k: v:
Evaluate k to a value kv.
If element has a null-aware key and kv is null, then stop. Else continue...
Evaluate v to a value vv.
If element has a null-aware value and vv is null, then stop. Else continue...
Append an entry kv: vv to result.
Metadata
Metadata
Assignees
Labels
feature-null-aware-elementsImplementation of the Null-aware elements featureImplementation of the Null-aware elements featurelegacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.model-featuresGeneral feature work in the analyzer and CFE.General feature work in the analyzer and CFE.soundnesstype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)