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

document automatic semicolon insertion (ASI) hazard? #49

Closed
dckc opened this issue Sep 14, 2020 · 3 comments
Closed

document automatic semicolon insertion (ASI) hazard? #49

dckc opened this issue Sep 14, 2020 · 3 comments

Comments

@dckc
Copy link
Contributor

dckc commented Sep 14, 2020

What exactly is the hazard / risk?

I filed tgrospic/rnode-client-js#16 asking @tgrospic to avoid it, but when I did so, I struggled to come up with any argument other than authority; i.e. Agoric says so (and Crockford used to say so). @tgrospic is (quite reasonably, as far as I can tell) pushing back.

@erights
Copy link
Contributor

erights commented Sep 14, 2020

Given the stated rules -- never start a line with [, (, , +, *, /, -, ,, .,` -- and given high quality IDE support, which is plausibly as good as he says, I can believe that the hazard goes away. But that's a lot of work and narrow set of assumptions for questionable benefit. I'd rather invest my IDE engineering on real problems, of which we have plenty.

@erights
Copy link
Contributor

erights commented Sep 14, 2020

To answer your question, "What exactly is the hazard/risk?", it is that the programmer thought they wrote a program whose parse would give it one meaning but the machine runs it as a program with a different meaning based on a different parse. Without his restrictions and IDE support there are plenty of examples caused by ASI. Given his restrictions and IDE support, I don't know if there are any examples where ASI causes such ambiguity.

Here's a tricky non-ASI example. What does the following code do as a script? As a CJS module? As an EcmaScript module? As an EcmaScript module packaged up by your favorite packer, say rollup?

let x = 8;
let y = 9;
let z = y <!--x;
console.log(z);

@dckc
Copy link
Contributor Author

dckc commented Sep 14, 2020

OK. Thanks. I recall that it simplifies writing a Jessie parser, which is probably enough motivation for this scope.

@dckc dckc closed this as completed Sep 14, 2020
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

2 participants