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

ReferenceError: use before declaration in Edge #59

Closed
jods4 opened this issue Mar 4, 2017 · 9 comments
Closed

ReferenceError: use before declaration in Edge #59

jods4 opened this issue Mar 4, 2017 · 9 comments
Labels

Comments

@jods4
Copy link
Contributor

jods4 commented Mar 4, 2017

The ES2015 distribution of aurelia-bootstrapper triggers an error in Edge: "ReferenceError: use before declaration". And then the application doesn't start.

I did test before and never noticed that, so I wonder if it is an Edge regression in a recent update.
I have Edge 14.14393, I would be interested in other people testing this.

The offending code is line 126:

.then(({ Aurelia }) => startResolve(() => new Aurelia(loader)));

And Aurelia is the variable that Edge complains about.
The code above looks fine to me (given that then is called with an object that contains an Aurelia property).
It runs fine in Firefox and according to Kangax tables it should be supported in Edge as well.

Just changing the code as follows work.

.then(({ Aurelia }) => { 
  return startResolve(() => new Aurelia(loader));
});

So I'd say this is more of an Edge bug, but since it impacts us it's good to know.

@jods4
Copy link
Contributor Author

jods4 commented Mar 4, 2017

I have a minimal repro, it requires several conditions to trigger the bug, notably nested lambdas.
This breaks Edge 14.4393:

function g(cb) { return g() }
let f = ({ x }) => g(() => x);
f({ x: 42 }); // should return 42 but throws "use before declaration".

@jods4
Copy link
Contributor Author

jods4 commented Mar 4, 2017

Found a relevant Chakra bug: chakra-core/ChakraCore#2606.
It was opened 5 days ago, I guess it is a recent update. :(

@niieani
Copy link
Contributor

niieani commented Mar 4, 2017

We don't need the lambda, we can use function notation if it's going to help, since we only use the scope anyway (no this calls). I'd say we can re-release with a workaround.
Good catch, by the way!

@jods4
Copy link
Contributor Author

jods4 commented Mar 4, 2017

The bug is not hard to work around as it's very sensible to syntax. Even just adding braces (block) make it vanish.

If we publish a fix the hardest part is making sure minifiers don't simplify the syntax back to broken. For instance, if we add braces or function I would expect a minifier to remove them...

It was not a hard catch as unfortunately now Aurelia ES6 does not run at all in Edge. 😦

@jods4
Copy link
Contributor Author

jods4 commented Mar 5, 2017

@EisenbergEffect do you want to publish a fix? I can PR one if you want to.

@EisenbergEffect
Copy link
Contributor

Oh, definitely. If you send a PR I'll get it out today.

jods4 added a commit to jods4/bootstrapper that referenced this issue Mar 5, 2017
@jods4
Copy link
Contributor Author

jods4 commented Mar 5, 2017

@EisenbergEffect The fix is in the linked PR, it works for me.

@EisenbergEffect
Copy link
Contributor

Merged.

@EisenbergEffect
Copy link
Contributor

Release coming in a few minutes.

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

No branches or pull requests

3 participants