-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.dart2js-ddc-discrepancyWhen dev and production compilations have different semanticsWhen dev and production compilations have different semanticsweb-dev-compiler
Description
import 'dart:js_interop';
@JS()
external String? get undefined;
void f([String? s = 'default']) {
print(s);
}
void main() {
f(undefined);
}The above prints default on DDC and null on dart2js (also null on dart2wasm, but that's because of how it's converted to null explicitly). This is because DDC lowers f to something like:
function f(s = 'default') {
dart.print(s);
}When undefined is passed, JS uses the default value instead. This is generally an okay way to lower this code if undefined never exists in the program, but with JS interop, that can't be guaranteed. Another way to reproduce this discrepancy is converting the above Dart function to JS and then calling it with undefined.
cc @nshahan
ykmnkmi
Metadata
Metadata
Assignees
Labels
area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.dart2js-ddc-discrepancyWhen dev and production compilations have different semanticsWhen dev and production compilations have different semanticsweb-dev-compiler