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

wrong scope in default function parameters #1604

Closed
zayani opened this issue Dec 19, 2014 · 5 comments
Closed

wrong scope in default function parameters #1604

zayani opened this issue Dec 19, 2014 · 5 comments

Comments

@zayani
Copy link

zayani commented Dec 19, 2014

consider this ES6 code:

var x=4;

function i(x=1,c=x)
{
  console.log(c); 
}

i(); //should print 4

var c inside the function should be 4 (x in outer scope) not 1 (x in the function scope), but the complied code give 1

$traceurRuntime.ModuleStore.getAnonymousModule(function() {
  "use strict";
  var x = 4;
  function i() {
    var x = arguments[0] !== (void 0) ? arguments[0] : 1;
    var c = arguments[1] !== (void 0) ? arguments[1] : x;
    console.log(c);
  }
  i(); // print 1
  return {};
});
@domenic
Copy link
Contributor

domenic commented Dec 19, 2014

1 is correct per ES6 spec. Why do you think it should be 4?

@UltCombo
Copy link
Contributor

dupe? #1376

@arv
Copy link
Collaborator

arv commented Dec 19, 2014

This bug is invalid.

#1376 is still a valid bug.

@arv arv closed this as completed Dec 19, 2014
@UltCombo
Copy link
Contributor

@zayani's latter comment contained a valid'ish example, though it looks like that comment has been deleted (?). I've deleted my reply to it as well since it'd make no sense now.

@arv
Copy link
Collaborator

arv commented Dec 19, 2014

Yeah, the x = x case should be covered by the TDZ.

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

No branches or pull requests

4 participants