Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Array.forEach facade produces invalid code #272

Closed
mhevery opened this issue Aug 28, 2015 · 3 comments
Closed

Array.forEach facade produces invalid code #272

mhevery opened this issue Aug 28, 2015 · 3 comments

Comments

@mhevery
Copy link

mhevery commented Aug 28, 2015

var a = [];
a.forEach((k, v) => { stmt1(); });

produces in dart

a.forEach((k, v) => { stmt1(); });

this is incorrect, since => and {} can not be used together. Valid outputs would either of these:

a.forEach((k, v) { stmt1(); });
a.forEach((k, v) => stmt1();});
@vicb vicb self-assigned this Aug 28, 2015
@vicb
Copy link
Contributor

vicb commented Aug 28, 2015

Not sure what's going wrong here, there is no special case for this one (i.e. any arrow function should be translated by ts2d whatever the context).

But you probably want to have a single argument for the cb - the item.

@jsayol
Copy link
Contributor

jsayol commented Jan 10, 2016

Just FYI, ts2dart already produces the correct output now ( a.forEach((k, v) { stmt1(); }); ) so this issue can be closed.

@mprobst
Copy link
Contributor

mprobst commented Jan 10, 2016

Thanks for pointing this out.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants