Skip to content

[dart devc] Pattern matching use same variable name cause unexpected behavior #54559

Closed
@huanghui1998hhh

Description

@huanghui1998hhh

Steps to reproduce

Create a flutter project and run flutter web on debug mode with this code:

void main() {
  String? fooValue = 'hello world';
  if (fooValue case final String fooValue) {
    print(fooValue);
  }
}

And this is it's js result:

  main.main = function main$() {
    let fooValue = "hello world";
    {
      let fooValue = null;
      let t$36$350$350 = fooValue;
      if (typeof t$36$350$350 == 'string') {
        fooValue = t$36$350$350;
        {
          core.print(fooValue);
        }
      }
    }
  };

So it will not print 'hello world'.

Metadata

Metadata

Assignees

Labels

area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.web-dev-compiler

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions