You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In other words, it looks like there is some sort of faulty optimization applied: As soon as the expression to iterate over is a bare variable, it is not rescued to a new local (here: _b). As shown, this results in wrong semantics.
The text was updated successfully, but these errors were encountered:
DanielRosenwasser
changed the title
Wrong ES3/ES5 code emitted for certain 'for...of' statements
Wrong ES3/ES5 code when iterated identifier is reassigned in a 'for...of' statement
Oct 30, 2015
Thanks for the bug report! You can try out our nightlies by installing npm install -g typescript@next by ~11:30 Pacific tonight or tomorrow morning and you should get the fix.
There is an inconsistency regarding the emitted ES3/ES5 code:
compiles to
printing
instead of (ES6 semantics)
(Note that the code emitted also differs from the feature description: #2207 (comment))
On the other hand, merely adding parentheses around the expression:
correctly compiles to
giving the expected output.
In other words, it looks like there is some sort of faulty optimization applied: As soon as the expression to iterate over is a bare variable, it is not rescued to a new local (here:
_b
). As shown, this results in wrong semantics.The text was updated successfully, but these errors were encountered: