Test update for proposed Annex B.3.5 simplification

This commit is contained in:
Ross Kirsling 2019-01-04 21:31:36 -08:00 committed by Rick Waldron
parent 9345023d5f
commit 815913a982
5 changed files with 38 additions and 33 deletions

View File

@ -9,16 +9,12 @@ info: |
This modified behaviour also applies to var and function declarations
introduced by direct evals contained within the Block of a Catch clause.
This change is accomplished by modify the algorithm of 18.2.1.2 as follows:
This change is accomplished by modifying the algorithm of 18.2.1.3 as follows:
Step 5.d.ii.2.a.i is replaced by:
i. If thisEnvRec is not the Environment Record for a Catch clause, throw a
SyntaxError exception.
ii. If name is bound by any syntactic form other than a
FunctionDeclaration, a VariableStatement, the VariableDeclarationList
of a for statement, or the ForBinding of a for-in statement, throw a
SyntaxError exception.
flags: [noStrict]
---*/
@ -26,7 +22,12 @@ try {
throw null;
} catch (err) {
eval('function err() {}');
eval('function* err() {}');
eval('async function err() {}');
eval('async function* err() {}');
eval('var err;');
eval('for (var err; false; ) {}');
eval('for (var err in []) {}');
eval('for (var err of []) {}');
}

View File

@ -6,9 +6,8 @@ es6id: B.3.5
description: Re-declaration of catch parameter (for-in statement)
info: |
It is a Syntax Error if any element of the BoundNames of CatchParameter
also occurs in the VarDeclaredNames of Block, unless that element is only
bound by a VariableStatement or the VariableDeclarationList of a for
statement, or the ForBinding of a for-in statement.
also occurs in the VarDeclaredNames of Block, unless CatchParameter is
CatchParameter : BindingIdentifier.
---*/
var before, during, after;

View File

@ -0,0 +1,27 @@
// 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-variablestatements-in-catch-blocks
es6id: B.3.5
description: Re-declaration of catch parameter (for-of statement)
info: |
It is a Syntax Error if any element of the BoundNames of CatchParameter
also occurs in the VarDeclaredNames of Block, unless CatchParameter is
CatchParameter : BindingIdentifier.
---*/
var before, during, after;
try {
throw 'exception';
} catch (err) {
before = err;
for (var err of [2]) {
during = err;
}
after = err;
}
assert.sameValue(before, 'exception');
assert.sameValue(during, 2, 'during loop body evaluation');
assert.sameValue(after, 2, 'after loop body evaluation');

View File

@ -3,12 +3,11 @@
/*---
esid: sec-variablestatements-in-catch-blocks
es6id: B.3.5
description: Re-declaration of catch parameter (for-in statement)
description: Re-declaration of catch parameter (for statement)
info: |
It is a Syntax Error if any element of the BoundNames of CatchParameter
also occurs in the VarDeclaredNames of Block, unless that element is only
bound by a VariableStatement or the VariableDeclarationList of a for
statement, or the ForBinding of a for-in statement.
also occurs in the VarDeclaredNames of Block, unless CatchParameter is
CatchParameter : BindingIdentifier.
---*/
var before, during, after;

View File

@ -1,21 +0,0 @@
// 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-evaldeclarationinstantiation
es6id: 18.2.1.2
description: Variable collision with lexical binding in lower scope
info: |
Annex B extensions permit re-declarations from FunctionDeclaration,
VariableStatement, the VariableDeclarationList of a for statement, and the
ForBinding of a for-in statement. Bindings from the ForBinding of a for-of
statement are restricted regardless of the application of Annex B.
flags: [noStrict]
---*/
assert.throws(SyntaxError, function() {
try {
throw null;
} catch (err) {
eval('for (var err of []) {}');
}
});