[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dart2js await for bug with nested loop #23119

Closed
sigurdm opened this issue Apr 7, 2015 · 4 comments
Closed

dart2js await for bug with nested loop #23119

sigurdm opened this issue Apr 7, 2015 · 4 comments

Comments

@sigurdm
Copy link
Contributor
sigurdm commented Apr 7, 2015

The program:

import 'dart:async';

p() async* {
  yield [1, 2, 3];
}

Stream<int> foo(Stream stream) async* {
  await for (List data in stream) {
    print('Will iterate ${data} ${data.runtimeType}');
    for (var i in data) {
      print('got $i');
    }
  }
}

main() async {
  var c;
  c = new StreamController(onListen: () async {
    c.add([1,2,3]);
  });
// foo(p()).listen((v) {});
  foo(c.stream).listen((v) {});
}

On the VM prints:
Will iterate [1, 2, 3] List
got 1
got 2
got 3

But on dart2js it prints:
Will iterate [1, 2, 3] JSArray

The js for the inner for loop (before async-translation) is

      for (t2 = J.get$iterator$a(data); t2.moveNext$0(), false;) {
        i = t2.get$current();
        line = "got " + H.S(i);
        H.printString(line);
      }

I am not sure where the , false comes from. It seems to be an inferrence problem. If the commented line is inserted the problem disappears.

@ghost
Copy link
ghost commented Apr 8, 2015

Set owner to @herhut-ggl.
Added Started label.

@ghost
Copy link
ghost commented Apr 9, 2015

Proposed fix in https://codereview.chromium.org/1069983005/.

@ghost
Copy link
ghost commented Apr 14, 2015

Fixed in revision r45059.


Added Fixed label.

@sigurdm
Copy link
Contributor Author
sigurdm commented Apr 20, 2015

Issue #23255 has been merged into this issue.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants