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

node-8.9.3 two immediate execution function error #18275

Closed
hhxx1994 opened this issue Jan 21, 2018 · 3 comments
Closed

node-8.9.3 two immediate execution function error #18275

hhxx1994 opened this issue Jan 21, 2018 · 3 comments

Comments

@hhxx1994
Copy link

  • Version: 8.9.3
  • Platform: window 7 x64 webstorm 2017.3.3
(() => console.log("a"))()
(() => console.log("b"))()
(() => console.log("b"))()
^

TypeError: (intermediate value)(...) is not a function
    at Object.<anonymous> (D:\workspace\fb\helloworld\helloworld.js:2:1)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3
a

but if I add a semicolon to one line is ok,like this

(() => console.log("a"))();
(() => console.log("b"))()
@nephross
Copy link
Contributor

Without knowing for sure, I would venture to guess this issue is similar in nature to this one: #18054

The automatic semicolon insertion performed by the V8 parser is not able to insert the semicolon in the correct spot for the code to execute as expected.

@lpinca
Copy link
Member

lpinca commented Jan 21, 2018

This works as intended as you are basically writing this

(() => {})()()

The last function call is done on something that isn't a function, thus the error.

@benjamingr
Copy link
Member

Hey, I'm going to go ahead and close this as this is expected JavaScript behavior and is not something Node.js can do anything about anyway.

Thank you so much for taking the time to report a potential bug!

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