arguments array doesn't work before defer #38

Open
sktaylor opened this Issue Apr 8, 2013 · 0 comments

Projects

None yet

1 participant

@sktaylor
Collaborator

Don't know if this is an easy one or not:

function argumentsDoNotWork(){
    console.dir(arguments);
    await{ setTimeout(defer(), 100);
}

argumentsDoNotWork("foo", "bar");

It's because the arguments array gets wrapped in an inner function by the parser. It makes sense to me I can't use arguments after the defer, but I'd expect I could use it before the defer. I can work around it by having a function without defer call the function with defer, but it's problematic because the code doesn't do what you'd expect. I ran around with this for a couple hours before I figured it out. If it's easy, a fix would be great. I'd do it but I don't understand the parser well enough. I figure you could do it quickly, or not at all. I imagine the fix might also allow you to do returns from the function before you hit the defer as well. For example:

function ret(){
    return(10);
    setTimeout(defer(), 100);
}

var ten = ret();

Best,

Kendrick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment