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

for...of and spread inside function : assignment to undeclared variable #712

Closed
dtinth opened this issue Feb 7, 2015 · 1 comment
Closed
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@dtinth
Copy link

dtinth commented Feb 7, 2015

My builds are failing. It turns out to be from 6to5.

This is kind of an edge case:

function test(arrays) {
  let math = Math
  for (let array of arrays) {
    math.max(...array)
  }
}

Generated JS:

"use strict";

var _toArray = function (arr) { return Array.isArray(arr) ? arr : Array.from(arr); };

function test(arrays) {
  var math = Math;
  for (var _iterator = arrays[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
    var array = _step.value;
    (_math = math).max.apply(_math, _toArray(array));
  }
}

You can see that the math object is assigned into _math without a var declaration.

Test:

test([[1, 2, 3], [5, 4]])

Error:

assignment to undeclared variable _math
@sebmck sebmck added bug labels Feb 7, 2015
@sebmck
Copy link
Contributor

sebmck commented Feb 7, 2015

Same issue as #710 which has now been fixed. Thanks!

@sebmck sebmck closed this as completed Feb 7, 2015
dtinth added a commit to bemusic/bemuse that referenced this issue Feb 8, 2015
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jan 18, 2019
@lock lock bot unassigned sebmck Jan 18, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
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