dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.22k stars 1.57k forks source link

Compiler generates invalid javascript #49814

Closed kika closed 2 years ago

kika commented 2 years ago

Steps to reproduce:

  1. go to https://dartpad.dev/
  2. Create a Flutter project (pure Dart will work too, but Flutter is just visually more obvious)
  3. Click "Run", see "Hello, world!"
  4. Paste the following code anywhere where syntactically appropriate
    enum BrushType {
    solid('Solid', null),  // Default brush
    brush1('Chisel', 'brush-1.png'),
    brush2('Flat','brush-2.png'),
    ;
    final String name;
    final String? asset;
    const BrushType(this.name, this.asset);
    }
  5. Click "Run"
  6. Oops.
  7. Open the browser devtools console and observe cryptic Uncaught SyntaxError: Duplicate parameter name not allowed in this context

During real Flutter development no diagnostic is ever produced anywhere besides the browser console, the flutter run -d chrome just sits stuck in "waiting for connection from debug service".

I'm using latest stable Flutter (3.0.5) and dartpad uses as of this writing 2.17.6

Not sure if related: https://github.com/dart-lang/sdk/issues/43362

kika commented 2 years ago

As in the linked issue, seems to be isolated to dartdevc (i.e. flutter run in my case). Building with flutter build doesn't result in any issues.

kika commented 2 years ago

Workaround: change final String name to final String nom (and constructor argument accordingly). So don't use name name. Chris Null sends his best wishes.

nshahan commented 2 years ago

@kika Thanks for the report. This has been fixed in the main branch 539cccd8234ee10fddca244d9855ce0e0e5d8c45 and will rollout with the next stable release.