Skip to content

Stringify closures consistently between Dart VM, dart2js, and DDC #37105

@yjbanov

Description

@yjbanov

dart2js and DDC stringify closures differently from the Dart VM. To avoid "browser quirks" in Flutter for web, we'd like the behavior to be consistent.

Example:

void main() {
  print(() {});
  print(fn);
}

void fn() {}

The Dart VM prints:

$ dart print_closure.dart
Closure: () => Null
Closure: () => void from Function 'fn': static.

dart2js output prints:

$ node out.js
Closure 'main_closure'
Closure 'fn'

Dart SDK info:

$ dart --version
Dart VM version: 2.3.1 (Tue May 21 19:28:38 2019 +0200) on "linux_x64"
$ dart2js --version
Dart-to-JavaScript compiler (dart2js) version: 2.3.1

I haven't tried DDC (I don't know how to use it from the command line), but I'm guessing it's not consistent either.

/cc @vsmenon @jonahwilliams

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onarea-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.web-dart2js

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions