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

ExportDeclaration and semicolons/ASI #284

Closed
mathiasbynens opened this issue Jan 13, 2016 · 2 comments
Closed

ExportDeclaration and semicolons/ASI #284

mathiasbynens opened this issue Jan 13, 2016 · 2 comments

Comments

@mathiasbynens
Copy link
Member

https://tc39.github.io/ecma262/#sec-automatic-semicolon-insertion explicitly mentions export statements:

Certain ECMAScript statements ([…] export declarations […]) must be terminated with semicolons. Such semicolons may always appear explicitly in the source text. For convenience, however, such semicolons may be omitted from the source text in certain situations. These situations are described by saying that semicolons are automatically inserted into the source code token stream in those situations.

Furthermore, table 43 (although purely illustrative) includes the semicolons in all of its examples: https://tc39.github.io/ecma262/#table-42

However, the ExportDeclaration grammar doesn’t include the semicolon for the following cases:

  • export HoistableDeclaration, e.g. export function foo() {}
  • export ClassDeclaration, e.g. export class Bar {}
  • export default HoistableDeclaration, e.g. export default function baz() {}
  • export default ClassDeclaration, e.g. export default class Qux {}

If the grammar is correct, then:

  1. https://tc39.github.io/ecma262/#sec-automatic-semicolon-insertion should probably be changed to exclude export since it’s currently overgeneralizing
  2. Table 43 should be changed to omit the semicolon after export default function f(){} and export default function(){}

cc @jmm

@allenwb
Copy link
Member

allenwb commented Jan 14, 2016

Yes, the grammar is correct.

I suggest rewriting the first sentence of https://tc39.github.io/ecma262/#sec-automatic-semicolon-insertion to be:

Certain ECMAScript statements (empty statement, let, const, import, and >>some<< export declarations...

and yes, remove the two semicolon in Table 43 on the function exports.

@jmm
Copy link
Contributor

jmm commented Jan 14, 2016

@allenwb 👍 That's what the most recent commit in #285 says now (though not that exact wording).

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

3 participants