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

es6.blockScopingTDZ creates invalid JS for for...in loop #1074

Closed
loganfsmyth opened this issue Mar 24, 2015 · 1 comment
Closed

es6.blockScopingTDZ creates invalid JS for for...in loop #1074

loganfsmyth opened this issue Mar 24, 2015 · 1 comment
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@loganfsmyth
Copy link
Member

let data = {};
let key;
for (key in data){
}

becomes

var _temporalAssertDefined = function (val, name, undef) { if (val === undef) { throw new ReferenceError(name + " is not defined - temporal dead zone"); } return true; };

var _temporalUndefined = {};

var data = _temporalUndefined;
var key = _temporalUndefined;
data = {};
key = undefined;
for (_temporalAssertDefined(key, "key", _temporalUndefined) && key in _temporalAssertDefined(data, "data", _temporalUndefined) && data) {}

Seems to be because the let key; is outside the for loop and used as a key.

@loganfsmyth loganfsmyth changed the title TDZ transformer for for...in creates invalid JS es6.blockScopingTDZ creates invalid JS for for...in loop Mar 24, 2015
@sebmck
Copy link
Contributor

sebmck commented Mar 25, 2015

Fixed in the experimental branch.

@sebmck sebmck closed this as completed Mar 25, 2015
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jul 24, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

2 participants