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

Miscompilation with spread operator and lack of semicolons. #210

Open
Dirbaio opened this issue Jul 10, 2019 · 1 comment
Open

Miscompilation with spread operator and lack of semicolons. #210

Dirbaio opened this issue Jul 10, 2019 · 1 comment
Labels

Comments

@Dirbaio
Copy link

Dirbaio commented Jul 10, 2019

https://buble.surge.sh/#function%20foobar(a%2C%20b)%20%7B%0A%20%20return%20%7B%0A%20%20%20%20foo%3A%20%5Ba%2C%20b%5D%2C%0A%20%20%20%20bar%3A%20%5Bb%2C%20a%5D%2C%0A%20%20%7D%3B%0A%7D%0A%0Afunction%20foo()%20%7B%0A%20%20%09const%20res%20%3D%20%7B%0A%20%20%20%20%09foo%3A%20%5B%5D%2C%0A%20%20%20%20%20%20%09bar%3A%20%5B%5D%2C%0A%20%20%20%20%7D%0A%20%20%20%20const%20r%20%3D%20foobar(1%2C%202)%0A%20%20%20%20res.foo.push(...r.foo)%0A%20%20%20%20res.bar.push(...r.bar)%0A%20%20%09return%20res%0A%7D%0A

Original code works, compiled code fails with foobar(...) is not a function.

This is because lack of semicolons makes the resulting code be executed like this:

    var r = foobar(1, 2)(ref = res.foo).push.apply(ref, r.foo)

while it should be like this

    var r = foobar(1, 2);
    (ref = res.foo).push.apply(ref, r.foo)
@mourner mourner added the bug label Jul 11, 2019
@mourner
Copy link
Collaborator

mourner commented Jul 11, 2019

Yep, that's a bug — thanks for reporting! Minimal repro: https://buble.surge.sh/#a()%0Ab.c.d(...e)

Dirbaio added a commit to akiles/vue-router that referenced this issue Jul 11, 2019
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

2 participants