I'm wondering if this is a compiler bug, or this is the way it's supposed to be.
Using node.js v10.15.3, this code throws an error:
var x
x = false
(function y() { console.log('foo') }())
But this code works fine:
var x
x = false;
(function y() { console.log('foo') }())
It's the semicolon that makes the difference. The error message is: "TypeError: false is not a function", so it appears that without the semicolon, the compiler is parsing the open paren after the "false" keyword as a function call, as if I had written "x = false()". It took me a long time to figure out what was going wrong in my code (which was more complex than the example above, obviously.) That's a chunk of my life I won't get back!
My question is: why? I thought semicolons were not necessary at the end of a line? I've just been reading the ECMA spec on semicolon insertion trying to figure this out, but it's still a little murky to me.
I guess the moral of the story is to just go ahead and terminate all lines with semicolons. The funny thing is that, as a C programmer, that was my habit, and I was just trying to catch up with the times by dropping all those unneeded semicolons.