Module code: early errors

Assert that relevant early errors are reported following the parsing of
module code.
This commit is contained in:
Mike Pennisi 2016-03-29 11:48:19 -04:00
parent 076480fc2d
commit cfd7e1f61d
6 changed files with 154 additions and 0 deletions

View File

@ -0,0 +1,15 @@
// 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-module-semantics-static-semantics-early-errors
es6id: 15.2.1.1
description: >
It is a Syntax Error if the ExportedNames of ModuleItemList contains any
duplicate entries.
flags: [module]
negative: SyntaxError
---*/
var x, y;
export default x;
export { y as default };

View File

@ -0,0 +1,15 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-module-semantics-static-semantics-early-errors
es6id: 15.2.1.1
description: Exporting a global binding
info: >
It is a Syntax Error if any element of the ExportedBindings of
ModuleItemList does not also occur in either the VarDeclaredNames of
ModuleItemList, or the LexicallyDeclaredNames of ModuleItemList.
flags: [module]
negative: SyntaxError
---*/
export { Number };

View File

@ -0,0 +1,31 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: ImportedBinding is a BindingIdentifier and cannot be "arguments"
esid: sec-imports
info: |
ImportSpecifier :
ImportedBinding
IdentifierName as ImportedBinding
ImportedBinding :
BindingIdentifier
12.1.1 Static Semantics : Early Errors
BindingIdentifier : Identifier
- It is a Syntax Error if the code matched by this production is contained
in strict mode code and the StringValue of Identifier is "arguments" or
"eval".
negative: SyntaxError
flags: [module]
---*/
// Create an appropriately-named ExportEntry in order to avoid false positives
// (e.g. cases where the implementation does not generate the expected early
// error but does produce a SyntaxError for unresolvable bindings).
var x;
export { x as arguments };
import { arguments } from './early-import-arguments.js';

View File

@ -0,0 +1,31 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: ImportedBinding is a BindingIdentifier and cannot be "arguments"
esid: sec-imports
info: |
ImportSpecifier :
ImportedBinding
IdentifierName as ImportedBinding
ImportedBinding :
BindingIdentifier
12.1.1 Static Semantics : Early Errors
BindingIdentifier : Identifier
- It is a Syntax Error if the code matched by this production is contained
in strict mode code and the StringValue of Identifier is "arguments" or
"eval".
negative: SyntaxError
flags: [module]
---*/
// Create an appropriately-named ExportEntry in order to avoid false positives
// (e.g. cases where the implementation does not generate the expected early
// error but does produce a SyntaxError for unresolvable bindings).
var x;
export { x };
import { x as arguments } from './early-import-as-arguments.js';

View File

@ -0,0 +1,31 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: ImportedBinding is a BindingIdentifier and cannot be "eval"
esid: sec-imports
info: |
ImportSpecifier :
ImportedBinding
IdentifierName as ImportedBinding
ImportedBinding :
BindingIdentifier
12.1.1 Static Semantics : Early Errors
BindingIdentifier : Identifier
- It is a Syntax Error if the code matched by this production is contained
in strict mode code and the StringValue of Identifier is "arguments" or
"eval".
negative: SyntaxError
flags: [module]
---*/
// Create an appropriately-named ExportEntry in order to avoid false positives
// (e.g. cases where the implementation does not generate the expected early
// error but does produce a SyntaxError for unresolvable bindings).
var x;
export { x };
import { x as eval } from './early-import-as-eval.js';

View File

@ -0,0 +1,31 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: ImportedBinding is a BindingIdentifier and cannot be "eval"
esid: sec-imports
info: |
ImportSpecifier :
ImportedBinding
IdentifierName as ImportedBinding
ImportedBinding :
BindingIdentifier
12.1.1 Static Semantics : Early Errors
BindingIdentifier : Identifier
- It is a Syntax Error if the code matched by this production is contained
in strict mode code and the StringValue of Identifier is "arguments" or
"eval".
negative: SyntaxError
flags: [module]
---*/
// Create an appropriately-named ExportEntry in order to avoid false positives
// (e.g. cases where the implementation does not generate the expected early
// error but does produce a SyntaxError for unresolvable bindings).
var x;
export { x as eval };
import { eval } from './early-import-eval.js';