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

Proposal: No-ASI mode #1064

Closed
manisenkov opened this Issue Jan 12, 2018 · 3 comments

Comments

Projects
None yet
5 participants
@manisenkov

manisenkov commented Jan 12, 2018

Inspired by debates at this PR.

Does it make sense to introduce No-ASI mode that can be activated, for instance, by "use noasi"; (similarily as "use strict"; for the strict mode) clause at the begin of the script?

At first look it could be simple to implement this mode in JS interpreters: whenever a case where normally semicolon must be automatically inserted is encountered, it just raise SyntaxError instead.

For instance:

"use noasi";

function foo () {
    return    // SyntaxError: semicolon is absent in "no-ASI" mode
        42;
}
@WebReflection

This comment has been minimized.

Show comment
Hide comment
@WebReflection

WebReflection Jan 12, 2018

I think it's been stated various times directives, such as 'use strict', won't ever be introduced again in the specs and this seems to be like a good fit for a linter (a new kind, if you want/need).

However, I like the SpiderMonkey behavior where you can (and you should) enable warnings and ASI mistakes will most likely come up (it's also funny the ASI, non-ASI debate always ends up with code nobody writes like the one in your example)

screenshot from 2018-01-12 14-49-56

TL;DR I think unreachable code warnings are a very good red flag for any production code so that, beside non-ASI gotchas, it'd be cool of engines would all offer similar SpiderMonkey functionality during syntax parsing/code analysis.

WebReflection commented Jan 12, 2018

I think it's been stated various times directives, such as 'use strict', won't ever be introduced again in the specs and this seems to be like a good fit for a linter (a new kind, if you want/need).

However, I like the SpiderMonkey behavior where you can (and you should) enable warnings and ASI mistakes will most likely come up (it's also funny the ASI, non-ASI debate always ends up with code nobody writes like the one in your example)

screenshot from 2018-01-12 14-49-56

TL;DR I think unreachable code warnings are a very good red flag for any production code so that, beside non-ASI gotchas, it'd be cool of engines would all offer similar SpiderMonkey functionality during syntax parsing/code analysis.

@erights

This comment has been minimized.

Show comment
Hide comment
@erights

erights Jan 12, 2018

I think it's been stated various times directives, such as 'use strict', won't ever be introduced again in the specs

@WebReflection There is no such absolute prohibition. Any proposal to add another would need to meet a very high bar. Indeed, a high enough bar that none is likely. However, if a proposal with a strong enough case is made, we would consider it.

erights commented Jan 12, 2018

I think it's been stated various times directives, such as 'use strict', won't ever be introduced again in the specs

@WebReflection There is no such absolute prohibition. Any proposal to add another would need to meet a very high bar. Indeed, a high enough bar that none is likely. However, if a proposal with a strong enough case is made, we would consider it.

@annevk

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk Jan 12, 2018

Contributor

This should probably be closed given that feature requests are not supposed to be made in this repository. Please see https://github.com/tc39/ecma262/blob/master/CONTRIBUTING.md for guidelines on how to propose a new feature.

Contributor

annevk commented Jan 12, 2018

This should probably be closed given that feature requests are not supposed to be made in this repository. Please see https://github.com/tc39/ecma262/blob/master/CONTRIBUTING.md for guidelines on how to propose a new feature.

@ljharb ljharb closed this Jan 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment