Merge pull request #560 from bocoup/modules-syntax

Module code: syntax validation
This commit is contained in:
Gorkem Yakin 2016-04-29 14:25:43 -07:00
commit f50cc81ace
102 changed files with 301 additions and 14 deletions

View File

@ -1,14 +0,0 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 15.2
description: >
An ImportDeclaration is not a valid StatementListItem and is therefore
restricted from appearing within statements in a ModuleBody.
flags: [module]
negative: SyntaxError
---*/
{
import { x } from 'y';
}

View File

@ -0,0 +1,11 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-exports
es6id: 15.2.3
description: The default export may not be a LexicalDeclaration (const)
flags: [module]
negative: SyntaxError
---*/
export default const x = null;

View File

@ -0,0 +1,21 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Expression not permitted in AssignmentExpression position
esid: sec-exports
info: |
ExportDeclaration:
export * FromClause;
export ExportClause FromClause;
export ExportClause;
export VariableStatement
export Declaration
export default HoistableDeclaration[Default]
export default ClassDeclaration[Default]
export default [lookahead { function, class }] AssignmentExpression[In];
negative: SyntaxError
flags: [module]
---*/
export default null, null;

View File

@ -0,0 +1,11 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-exports
es6id: 15.2.3
description: The default export may not be a LexicalDeclaration (let)
flags: [module]
negative: SyntaxError
---*/
export default let x;

View File

@ -0,0 +1,11 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-exports
es6id: 15.2.3
description: The default export may not be a VariableStatement
flags: [module]
negative: SyntaxError
---*/
export default var x;

View File

@ -0,0 +1,21 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Function declarations are interpreted as lexically-scoped in module code
esid: sec-module-semantics-static-semantics-lexicallydeclarednames
info: |
ModuleItem : StatementListItem
1. Return LexicallyDeclaredNames of StatementListItem.
15.2.1.1 Static Semantics: Early Errors
- It is a Syntax Error if any element of the LexicallyDeclaredNames of
ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList.
negative: SyntaxError
flags: [module]
---*/
var f;
function f() {}

View File

@ -0,0 +1,22 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Generator function declarations are interpreted as lexically-scoped in
module code
esid: sec-module-semantics-static-semantics-lexicallydeclarednames
info: |
ModuleItem : StatementListItem
1. Return LexicallyDeclaredNames of StatementListItem.
15.2.1.1 Static Semantics: Early Errors
- It is a Syntax Error if any element of the LexicallyDeclaredNames of
ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList.
negative: SyntaxError
flags: [module]
---*/
var g;
function* g() {}

View File

@ -0,0 +1,21 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Anonymous function declaration must not be interpreted as an expression
esid: sec-exports
info: |
ExportDeclaration:
export * FromClause;
export ExportClause FromClause;
export ExportClause;
export VariableStatement
export Declaration
export default HoistableDeclaration[Default]
export default ClassDeclaration[Default]
export default [lookahead { function, class }] AssignmentExpression[In];
negative: SyntaxError
flags: [module]
---*/
export default function() {}();

View File

@ -0,0 +1,22 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Anonymous generator function declaration must not be interpreted as an
expression
esid: sec-exports
info: |
ExportDeclaration:
export * FromClause;
export ExportClause FromClause;
export ExportClause;
export VariableStatement
export Declaration
export default HoistableDeclaration[Default]
export default ClassDeclaration[Default]
export default [lookahead { function, class }] AssignmentExpression[In];
negative: SyntaxError
flags: [module]
---*/
export default function* () {}();

View File

@ -0,0 +1,18 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Early ReferenceError resulting from module parsing
esid: sec-parsemodule
negative: ReferenceError
info: |
[...]
2. Parse sourceText using Module as the goal symbol and analyze the parse
result for any Early Error conditions. If the parse was successful and
no early errors were found, let body be the resulting parse tree.
Otherwise, let body be a List of one or more SyntaxError or
ReferenceError objects representing the parsing errors and/or early
errors.
flags: [module]
---*/
1++;

View File

@ -0,0 +1,22 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
"export default AssignmentExpression" declarations require a trailing
semicolon or LineTerminator
esid: sec-exports
info: |
ExportDeclaration:
export * FromClause;
export ExportClause FromClause;
export ExportClause;
export VariableStatement
export Declaration
export default HoistableDeclaration[Default]
export default ClassDeclaration[Default]
export default [lookahead { function, class }] AssignmentExpression[In];
negative: SyntaxError
flags: [module]
---*/
export default null null;

View File

@ -0,0 +1,22 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
"export ExportClause FromClause" declarations require a trailing semicolon
or LineTerminator
esid: sec-exports
info: |
ExportDeclaration:
export * FromClause;
export ExportClause FromClause;
export ExportClause;
export VariableStatement
export Declaration
export default HoistableDeclaration[Default]
export default ClassDeclaration[Default]
export default [lookahead { function, class }] AssignmentExpression[In];
negative: SyntaxError
flags: [module]
---*/
export {} from './parse-err-semi-export-clause-from.js' null;

View File

@ -0,0 +1,22 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
"export ExportClause" declarations require a trailing semicolon or
LineTerminator
esid: sec-exports
info: |
ExportDeclaration:
export * FromClause;
export ExportClause FromClause;
export ExportClause;
export VariableStatement
export Declaration
export default HoistableDeclaration[Default]
export default ClassDeclaration[Default]
export default [lookahead { function, class }] AssignmentExpression[In];
negative: SyntaxError
flags: [module]
---*/
export {} null;

View File

@ -0,0 +1,21 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
"export *" declarations require a trailing semicolon or LineTerminator
esid: sec-exports
info: |
ExportDeclaration:
export * FromClause;
export ExportClause FromClause;
export ExportClause;
export VariableStatement
export Declaration
export default HoistableDeclaration[Default]
export default ClassDeclaration[Default]
export default [lookahead { function, class }] AssignmentExpression[In];
negative: SyntaxError
flags: [module]
---*/
export * from './parse-err-semi-export-star.js' null;

Some files were not shown because too many files have changed in this diff Show More