mirror of
https://github.com/tc39/test262.git
synced 2025-07-26 07:25:15 +02:00
Generate tests
This commit is contained in:
parent
ad62d5b815
commit
d8c686e310
@ -0,0 +1,47 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-block-scoping.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: A block-scoped binding is created (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
13.2.14 Runtime Semantics: BlockDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
4. For each element d in declarations do
|
||||||
|
a. For each element dn of the BoundNames of d do
|
||||||
|
i. If IsConstantDeclaration of d is true, then
|
||||||
|
[...]
|
||||||
|
ii. Else,
|
||||||
|
2. Perform ! envRec.CreateMutableBinding(dn, false).
|
||||||
|
|
||||||
|
b. If d is a GeneratorDeclaration production or a FunctionDeclaration
|
||||||
|
production, then
|
||||||
|
i. Let fn be the sole element of the BoundNames of d.
|
||||||
|
ii. Let fo be the result of performing InstantiateFunctionObject for
|
||||||
|
d with argument env.
|
||||||
|
iii. Perform envRec.InitializeBinding(fn, fo).
|
||||||
|
---*/
|
||||||
|
var initialBV, currentBV, varBinding;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'{ function f() { initialBV = f; f = 123; currentBV = f; return "decl"; } }varBinding = f;\
|
||||||
|
f();'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
initialBV(),
|
||||||
|
'decl',
|
||||||
|
'Block-scoped binding value is function object at execution time'
|
||||||
|
);
|
||||||
|
assert.sameValue(currentBV, 123, 'Block-scoped binding is mutable');
|
||||||
|
assert.sameValue(
|
||||||
|
varBinding(),
|
||||||
|
'decl',
|
||||||
|
'Block-scoped binding is independent of outer var-scoped binding'
|
||||||
|
);
|
@ -0,0 +1,28 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-block-fn-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Does not re-initialize binding created by similar forms (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;\
|
||||||
|
\
|
||||||
|
{\
|
||||||
|
function f() {}\
|
||||||
|
}{ function f() { } }'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, undefined);
|
@ -0,0 +1,37 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-block-fn-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var updated;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'{\
|
||||||
|
function f() {\
|
||||||
|
return "first declaration";\
|
||||||
|
}\
|
||||||
|
}{ function f() { return "second declaration"; } }updated = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof updated, 'function');
|
||||||
|
assert.sameValue(updated(), 'second declaration');
|
@ -0,0 +1,34 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-fn-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Existing variable binding is not modified (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;{ function f() { return "inner declaration"; } }function f() {\
|
||||||
|
return "outer declaration";\
|
||||||
|
}'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init(), 'outer declaration');
|
@ -0,0 +1,37 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-fn-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated following evaluation (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'{ function f() { return "inner declaration"; } }after = f;\
|
||||||
|
\
|
||||||
|
function f() {\
|
||||||
|
return "outer declaration";\
|
||||||
|
}'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'inner declaration');
|
@ -0,0 +1,25 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-var-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Existing variable binding is not modified (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'var f = 123;\
|
||||||
|
init = f;{ function f() { } }'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, 123);
|
@ -0,0 +1,36 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-var-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated following evaluation (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'{ function f() { return "function declaration"; } }after = f;\
|
||||||
|
\
|
||||||
|
var f = 123;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'function declaration');
|
||||||
|
|
@ -0,0 +1,37 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Variable binding is initialized to `undefined` in outer scope (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
i. If varEnvRec is a global Environment Record, then
|
||||||
|
[...]
|
||||||
|
ii. Else,
|
||||||
|
i. Let bindingExists be varEnvRec.HasBinding(F).
|
||||||
|
ii. If bindingExists is false, then
|
||||||
|
i. Perform ! varEnvRec.CreateMutableBinding(F, true).
|
||||||
|
ii. Perform ! varEnvRec.InitializeBinding(F, undefined).
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, changed;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;\
|
||||||
|
f = 123;\
|
||||||
|
changed = f;{ function f() { } }'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, undefined, 'binding is initialized to `undefined`');
|
||||||
|
assert.sameValue(changed, 123, 'binding is mutable');
|
||||||
|
assert.throws(ReferenceError, function() {
|
||||||
|
f;
|
||||||
|
}, 'global binding is not created');
|
@ -0,0 +1,29 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-no-skip-param.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Extension observed when there is a formal parameter with the same name (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
ii. If replacing the FunctionDeclaration f with a VariableStatement that
|
||||||
|
has F as a BindingIdentifier would not produce any Early Errors for
|
||||||
|
body, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, after;
|
||||||
|
|
||||||
|
(function(f) {
|
||||||
|
eval(
|
||||||
|
'init = f;{ function f() { } }after = f;'
|
||||||
|
);
|
||||||
|
}(123));
|
||||||
|
|
||||||
|
assert.sameValue(init, 123, 'binding is not initialized to `undefined`');
|
||||||
|
assert.sameValue(
|
||||||
|
typeof after, 'function', 'value is updated following evaluation'
|
||||||
|
);
|
@ -0,0 +1,28 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-skip-early-err.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Extension not observed when creation of variable binding would produce an early error (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
ii. If replacing the FunctionDeclaration f with a VariableStatement that
|
||||||
|
has F as a BindingIdentifier would not produce any Early Errors for
|
||||||
|
body, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'let f = 123;\
|
||||||
|
init = f;{ function f() { } }after = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, 123, 'binding is not initialized to `undefined`');
|
||||||
|
assert.sameValue(after, 123, 'value is not updated following evaluation');
|
@ -0,0 +1,33 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Variable binding value is updated following evaluation (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'{ function f() { return "declaration"; } }after = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'declaration');
|
@ -0,0 +1,56 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-block-scoping.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-a.template
|
||||||
|
/*---
|
||||||
|
description: A block-scoped binding is created (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
13.2.14 Runtime Semantics: BlockDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
4. For each element d in declarations do
|
||||||
|
a. For each element dn of the BoundNames of d do
|
||||||
|
i. If IsConstantDeclaration of d is true, then
|
||||||
|
[...]
|
||||||
|
ii. Else,
|
||||||
|
2. Perform ! envRec.CreateMutableBinding(dn, false).
|
||||||
|
|
||||||
|
b. If d is a GeneratorDeclaration production or a FunctionDeclaration
|
||||||
|
production, then
|
||||||
|
i. Let fn be the sole element of the BoundNames of d.
|
||||||
|
ii. Let fo be the result of performing InstantiateFunctionObject for
|
||||||
|
d with argument env.
|
||||||
|
iii. Perform envRec.InitializeBinding(fn, fo).
|
||||||
|
---*/
|
||||||
|
var initialBV, currentBV, varBinding;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'if (true) function f() { initialBV = f; f = 123; currentBV = f; return "decl"; } else function _f() {}varBinding = f;\
|
||||||
|
f();'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
initialBV(),
|
||||||
|
'decl',
|
||||||
|
'Block-scoped binding value is function object at execution time'
|
||||||
|
);
|
||||||
|
assert.sameValue(currentBV, 123, 'Block-scoped binding is mutable');
|
||||||
|
assert.sameValue(
|
||||||
|
varBinding(),
|
||||||
|
'decl',
|
||||||
|
'Block-scoped binding is independent of outer var-scoped binding'
|
||||||
|
);
|
@ -0,0 +1,37 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-block-fn-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-a.template
|
||||||
|
/*---
|
||||||
|
description: Does not re-initialize binding created by similar forms (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;\
|
||||||
|
\
|
||||||
|
{\
|
||||||
|
function f() {}\
|
||||||
|
}if (true) function f() { } else function _f() {}'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, undefined);
|
@ -0,0 +1,46 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-block-fn-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-a.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var updated;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'{\
|
||||||
|
function f() {\
|
||||||
|
return "first declaration";\
|
||||||
|
}\
|
||||||
|
}if (true) function f() { return "second declaration"; } else function _f() {}updated = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof updated, 'function');
|
||||||
|
assert.sameValue(updated(), 'second declaration');
|
@ -0,0 +1,43 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-fn-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-a.template
|
||||||
|
/*---
|
||||||
|
description: Existing variable binding is not modified (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;if (true) function f() { return "inner declaration"; } else function _f() {}function f() {\
|
||||||
|
return "outer declaration";\
|
||||||
|
}'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init(), 'outer declaration');
|
@ -0,0 +1,46 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-fn-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-a.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated following evaluation (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'if (true) function f() { return "inner declaration"; } else function _f() {}after = f;\
|
||||||
|
\
|
||||||
|
function f() {\
|
||||||
|
return "outer declaration";\
|
||||||
|
}'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'inner declaration');
|
@ -0,0 +1,34 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-var-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-a.template
|
||||||
|
/*---
|
||||||
|
description: Existing variable binding is not modified (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'var f = 123;\
|
||||||
|
init = f;if (true) function f() { } else function _f() {}'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, 123);
|
@ -0,0 +1,45 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-var-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-a.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated following evaluation (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'if (true) function f() { return "function declaration"; } else function _f() {}after = f;\
|
||||||
|
\
|
||||||
|
var f = 123;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'function declaration');
|
||||||
|
|
@ -0,0 +1,46 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-a.template
|
||||||
|
/*---
|
||||||
|
description: Variable binding is initialized to `undefined` in outer scope (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
i. If varEnvRec is a global Environment Record, then
|
||||||
|
[...]
|
||||||
|
ii. Else,
|
||||||
|
i. Let bindingExists be varEnvRec.HasBinding(F).
|
||||||
|
ii. If bindingExists is false, then
|
||||||
|
i. Perform ! varEnvRec.CreateMutableBinding(F, true).
|
||||||
|
ii. Perform ! varEnvRec.InitializeBinding(F, undefined).
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, changed;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;\
|
||||||
|
f = 123;\
|
||||||
|
changed = f;if (true) function f() { } else function _f() {}'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, undefined, 'binding is initialized to `undefined`');
|
||||||
|
assert.sameValue(changed, 123, 'binding is mutable');
|
||||||
|
assert.throws(ReferenceError, function() {
|
||||||
|
f;
|
||||||
|
}, 'global binding is not created');
|
@ -0,0 +1,38 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-no-skip-param.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-a.template
|
||||||
|
/*---
|
||||||
|
description: Extension observed when there is a formal parameter with the same name (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
ii. If replacing the FunctionDeclaration f with a VariableStatement that
|
||||||
|
has F as a BindingIdentifier would not produce any Early Errors for
|
||||||
|
body, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, after;
|
||||||
|
|
||||||
|
(function(f) {
|
||||||
|
eval(
|
||||||
|
'init = f;if (true) function f() { } else function _f() {}after = f;'
|
||||||
|
);
|
||||||
|
}(123));
|
||||||
|
|
||||||
|
assert.sameValue(init, 123, 'binding is not initialized to `undefined`');
|
||||||
|
assert.sameValue(
|
||||||
|
typeof after, 'function', 'value is updated following evaluation'
|
||||||
|
);
|
@ -0,0 +1,37 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-skip-early-err.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-a.template
|
||||||
|
/*---
|
||||||
|
description: Extension not observed when creation of variable binding would produce an early error (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
ii. If replacing the FunctionDeclaration f with a VariableStatement that
|
||||||
|
has F as a BindingIdentifier would not produce any Early Errors for
|
||||||
|
body, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'let f = 123;\
|
||||||
|
init = f;if (true) function f() { } else function _f() {}after = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, 123, 'binding is not initialized to `undefined`');
|
||||||
|
assert.sameValue(after, 123, 'value is not updated following evaluation');
|
@ -0,0 +1,42 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-a.template
|
||||||
|
/*---
|
||||||
|
description: Variable binding value is updated following evaluation (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'if (true) function f() { return "declaration"; } else function _f() {}after = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'declaration');
|
@ -0,0 +1,56 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-block-scoping.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-b.template
|
||||||
|
/*---
|
||||||
|
description: A block-scoped binding is created (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
13.2.14 Runtime Semantics: BlockDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
4. For each element d in declarations do
|
||||||
|
a. For each element dn of the BoundNames of d do
|
||||||
|
i. If IsConstantDeclaration of d is true, then
|
||||||
|
[...]
|
||||||
|
ii. Else,
|
||||||
|
2. Perform ! envRec.CreateMutableBinding(dn, false).
|
||||||
|
|
||||||
|
b. If d is a GeneratorDeclaration production or a FunctionDeclaration
|
||||||
|
production, then
|
||||||
|
i. Let fn be the sole element of the BoundNames of d.
|
||||||
|
ii. Let fo be the result of performing InstantiateFunctionObject for
|
||||||
|
d with argument env.
|
||||||
|
iii. Perform envRec.InitializeBinding(fn, fo).
|
||||||
|
---*/
|
||||||
|
var initialBV, currentBV, varBinding;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'if (false) function _f() {} else function f() { initialBV = f; f = 123; currentBV = f; return "decl"; }varBinding = f;\
|
||||||
|
f();'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
initialBV(),
|
||||||
|
'decl',
|
||||||
|
'Block-scoped binding value is function object at execution time'
|
||||||
|
);
|
||||||
|
assert.sameValue(currentBV, 123, 'Block-scoped binding is mutable');
|
||||||
|
assert.sameValue(
|
||||||
|
varBinding(),
|
||||||
|
'decl',
|
||||||
|
'Block-scoped binding is independent of outer var-scoped binding'
|
||||||
|
);
|
@ -0,0 +1,37 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-block-fn-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-b.template
|
||||||
|
/*---
|
||||||
|
description: Does not re-initialize binding created by similar forms (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;\
|
||||||
|
\
|
||||||
|
{\
|
||||||
|
function f() {}\
|
||||||
|
}if (false) function _f() {} else function f() { }'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, undefined);
|
@ -0,0 +1,46 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-block-fn-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-b.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var updated;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'{\
|
||||||
|
function f() {\
|
||||||
|
return "first declaration";\
|
||||||
|
}\
|
||||||
|
}if (false) function _f() {} else function f() { return "second declaration"; }updated = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof updated, 'function');
|
||||||
|
assert.sameValue(updated(), 'second declaration');
|
@ -0,0 +1,43 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-fn-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-b.template
|
||||||
|
/*---
|
||||||
|
description: Existing variable binding is not modified (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;if (false) function _f() {} else function f() { return "inner declaration"; }function f() {\
|
||||||
|
return "outer declaration";\
|
||||||
|
}'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init(), 'outer declaration');
|
@ -0,0 +1,46 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-fn-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-b.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated following evaluation (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'if (false) function _f() {} else function f() { return "inner declaration"; }after = f;\
|
||||||
|
\
|
||||||
|
function f() {\
|
||||||
|
return "outer declaration";\
|
||||||
|
}'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'inner declaration');
|
@ -0,0 +1,34 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-var-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-b.template
|
||||||
|
/*---
|
||||||
|
description: Existing variable binding is not modified (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'var f = 123;\
|
||||||
|
init = f;if (false) function _f() {} else function f() { }'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, 123);
|
@ -0,0 +1,45 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-var-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-b.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated following evaluation (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'if (false) function _f() {} else function f() { return "function declaration"; }after = f;\
|
||||||
|
\
|
||||||
|
var f = 123;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'function declaration');
|
||||||
|
|
@ -0,0 +1,46 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-b.template
|
||||||
|
/*---
|
||||||
|
description: Variable binding is initialized to `undefined` in outer scope (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
i. If varEnvRec is a global Environment Record, then
|
||||||
|
[...]
|
||||||
|
ii. Else,
|
||||||
|
i. Let bindingExists be varEnvRec.HasBinding(F).
|
||||||
|
ii. If bindingExists is false, then
|
||||||
|
i. Perform ! varEnvRec.CreateMutableBinding(F, true).
|
||||||
|
ii. Perform ! varEnvRec.InitializeBinding(F, undefined).
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, changed;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;\
|
||||||
|
f = 123;\
|
||||||
|
changed = f;if (false) function _f() {} else function f() { }'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, undefined, 'binding is initialized to `undefined`');
|
||||||
|
assert.sameValue(changed, 123, 'binding is mutable');
|
||||||
|
assert.throws(ReferenceError, function() {
|
||||||
|
f;
|
||||||
|
}, 'global binding is not created');
|
@ -0,0 +1,38 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-no-skip-param.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-b.template
|
||||||
|
/*---
|
||||||
|
description: Extension observed when there is a formal parameter with the same name (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
ii. If replacing the FunctionDeclaration f with a VariableStatement that
|
||||||
|
has F as a BindingIdentifier would not produce any Early Errors for
|
||||||
|
body, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, after;
|
||||||
|
|
||||||
|
(function(f) {
|
||||||
|
eval(
|
||||||
|
'init = f;if (false) function _f() {} else function f() { }after = f;'
|
||||||
|
);
|
||||||
|
}(123));
|
||||||
|
|
||||||
|
assert.sameValue(init, 123, 'binding is not initialized to `undefined`');
|
||||||
|
assert.sameValue(
|
||||||
|
typeof after, 'function', 'value is updated following evaluation'
|
||||||
|
);
|
@ -0,0 +1,37 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-skip-early-err.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-b.template
|
||||||
|
/*---
|
||||||
|
description: Extension not observed when creation of variable binding would produce an early error (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
ii. If replacing the FunctionDeclaration f with a VariableStatement that
|
||||||
|
has F as a BindingIdentifier would not produce any Early Errors for
|
||||||
|
body, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'let f = 123;\
|
||||||
|
init = f;if (false) function _f() {} else function f() { }after = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, 123, 'binding is not initialized to `undefined`');
|
||||||
|
assert.sameValue(after, 123, 'value is not updated following evaluation');
|
@ -0,0 +1,42 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-b.template
|
||||||
|
/*---
|
||||||
|
description: Variable binding value is updated following evaluation (IfStatement with a declaration in both statement positions in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'if (false) function _f() {} else function f() { return "declaration"; }after = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'declaration');
|
@ -0,0 +1,56 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-block-scoping.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-stmt.template
|
||||||
|
/*---
|
||||||
|
description: A block-scoped binding is created (IfStatement with a declaration in the first statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
13.2.14 Runtime Semantics: BlockDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
4. For each element d in declarations do
|
||||||
|
a. For each element dn of the BoundNames of d do
|
||||||
|
i. If IsConstantDeclaration of d is true, then
|
||||||
|
[...]
|
||||||
|
ii. Else,
|
||||||
|
2. Perform ! envRec.CreateMutableBinding(dn, false).
|
||||||
|
|
||||||
|
b. If d is a GeneratorDeclaration production or a FunctionDeclaration
|
||||||
|
production, then
|
||||||
|
i. Let fn be the sole element of the BoundNames of d.
|
||||||
|
ii. Let fo be the result of performing InstantiateFunctionObject for
|
||||||
|
d with argument env.
|
||||||
|
iii. Perform envRec.InitializeBinding(fn, fo).
|
||||||
|
---*/
|
||||||
|
var initialBV, currentBV, varBinding;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'if (true) function f() { initialBV = f; f = 123; currentBV = f; return "decl"; } else ;varBinding = f;\
|
||||||
|
f();'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
initialBV(),
|
||||||
|
'decl',
|
||||||
|
'Block-scoped binding value is function object at execution time'
|
||||||
|
);
|
||||||
|
assert.sameValue(currentBV, 123, 'Block-scoped binding is mutable');
|
||||||
|
assert.sameValue(
|
||||||
|
varBinding(),
|
||||||
|
'decl',
|
||||||
|
'Block-scoped binding is independent of outer var-scoped binding'
|
||||||
|
);
|
@ -0,0 +1,37 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-block-fn-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-stmt.template
|
||||||
|
/*---
|
||||||
|
description: Does not re-initialize binding created by similar forms (IfStatement with a declaration in the first statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;\
|
||||||
|
\
|
||||||
|
{\
|
||||||
|
function f() {}\
|
||||||
|
}if (true) function f() { } else ;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, undefined);
|
@ -0,0 +1,46 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-block-fn-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-stmt.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated (IfStatement with a declaration in the first statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var updated;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'{\
|
||||||
|
function f() {\
|
||||||
|
return "first declaration";\
|
||||||
|
}\
|
||||||
|
}if (true) function f() { return "second declaration"; } else ;updated = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof updated, 'function');
|
||||||
|
assert.sameValue(updated(), 'second declaration');
|
@ -0,0 +1,43 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-fn-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-stmt.template
|
||||||
|
/*---
|
||||||
|
description: Existing variable binding is not modified (IfStatement with a declaration in the first statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;if (true) function f() { return "inner declaration"; } else ;function f() {\
|
||||||
|
return "outer declaration";\
|
||||||
|
}'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init(), 'outer declaration');
|
@ -0,0 +1,46 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-fn-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-stmt.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated following evaluation (IfStatement with a declaration in the first statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'if (true) function f() { return "inner declaration"; } else ;after = f;\
|
||||||
|
\
|
||||||
|
function f() {\
|
||||||
|
return "outer declaration";\
|
||||||
|
}'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'inner declaration');
|
@ -0,0 +1,34 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-var-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-stmt.template
|
||||||
|
/*---
|
||||||
|
description: Existing variable binding is not modified (IfStatement with a declaration in the first statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'var f = 123;\
|
||||||
|
init = f;if (true) function f() { } else ;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, 123);
|
@ -0,0 +1,45 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-var-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-stmt.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated following evaluation (IfStatement with a declaration in the first statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'if (true) function f() { return "function declaration"; } else ;after = f;\
|
||||||
|
\
|
||||||
|
var f = 123;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'function declaration');
|
||||||
|
|
@ -0,0 +1,46 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-stmt.template
|
||||||
|
/*---
|
||||||
|
description: Variable binding is initialized to `undefined` in outer scope (IfStatement with a declaration in the first statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
i. If varEnvRec is a global Environment Record, then
|
||||||
|
[...]
|
||||||
|
ii. Else,
|
||||||
|
i. Let bindingExists be varEnvRec.HasBinding(F).
|
||||||
|
ii. If bindingExists is false, then
|
||||||
|
i. Perform ! varEnvRec.CreateMutableBinding(F, true).
|
||||||
|
ii. Perform ! varEnvRec.InitializeBinding(F, undefined).
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, changed;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;\
|
||||||
|
f = 123;\
|
||||||
|
changed = f;if (true) function f() { } else ;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, undefined, 'binding is initialized to `undefined`');
|
||||||
|
assert.sameValue(changed, 123, 'binding is mutable');
|
||||||
|
assert.throws(ReferenceError, function() {
|
||||||
|
f;
|
||||||
|
}, 'global binding is not created');
|
@ -0,0 +1,38 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-no-skip-param.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-stmt.template
|
||||||
|
/*---
|
||||||
|
description: Extension observed when there is a formal parameter with the same name (IfStatement with a declaration in the first statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
ii. If replacing the FunctionDeclaration f with a VariableStatement that
|
||||||
|
has F as a BindingIdentifier would not produce any Early Errors for
|
||||||
|
body, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, after;
|
||||||
|
|
||||||
|
(function(f) {
|
||||||
|
eval(
|
||||||
|
'init = f;if (true) function f() { } else ;after = f;'
|
||||||
|
);
|
||||||
|
}(123));
|
||||||
|
|
||||||
|
assert.sameValue(init, 123, 'binding is not initialized to `undefined`');
|
||||||
|
assert.sameValue(
|
||||||
|
typeof after, 'function', 'value is updated following evaluation'
|
||||||
|
);
|
@ -0,0 +1,37 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-skip-early-err.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-stmt.template
|
||||||
|
/*---
|
||||||
|
description: Extension not observed when creation of variable binding would produce an early error (IfStatement with a declaration in the first statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
ii. If replacing the FunctionDeclaration f with a VariableStatement that
|
||||||
|
has F as a BindingIdentifier would not produce any Early Errors for
|
||||||
|
body, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'let f = 123;\
|
||||||
|
init = f;if (true) function f() { } else ;after = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, 123, 'binding is not initialized to `undefined`');
|
||||||
|
assert.sameValue(after, 123, 'value is not updated following evaluation');
|
@ -0,0 +1,42 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-else-stmt.template
|
||||||
|
/*---
|
||||||
|
description: Variable binding value is updated following evaluation (IfStatement with a declaration in the first statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'if (true) function f() { return "declaration"; } else ;after = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'declaration');
|
@ -0,0 +1,56 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-block-scoping.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-no-else.template
|
||||||
|
/*---
|
||||||
|
description: A block-scoped binding is created (IfStatement without an else clause in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
13.2.14 Runtime Semantics: BlockDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
4. For each element d in declarations do
|
||||||
|
a. For each element dn of the BoundNames of d do
|
||||||
|
i. If IsConstantDeclaration of d is true, then
|
||||||
|
[...]
|
||||||
|
ii. Else,
|
||||||
|
2. Perform ! envRec.CreateMutableBinding(dn, false).
|
||||||
|
|
||||||
|
b. If d is a GeneratorDeclaration production or a FunctionDeclaration
|
||||||
|
production, then
|
||||||
|
i. Let fn be the sole element of the BoundNames of d.
|
||||||
|
ii. Let fo be the result of performing InstantiateFunctionObject for
|
||||||
|
d with argument env.
|
||||||
|
iii. Perform envRec.InitializeBinding(fn, fo).
|
||||||
|
---*/
|
||||||
|
var initialBV, currentBV, varBinding;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'if (true) function f() { initialBV = f; f = 123; currentBV = f; return "decl"; }varBinding = f;\
|
||||||
|
f();'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
initialBV(),
|
||||||
|
'decl',
|
||||||
|
'Block-scoped binding value is function object at execution time'
|
||||||
|
);
|
||||||
|
assert.sameValue(currentBV, 123, 'Block-scoped binding is mutable');
|
||||||
|
assert.sameValue(
|
||||||
|
varBinding(),
|
||||||
|
'decl',
|
||||||
|
'Block-scoped binding is independent of outer var-scoped binding'
|
||||||
|
);
|
@ -0,0 +1,37 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-block-fn-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-no-else.template
|
||||||
|
/*---
|
||||||
|
description: Does not re-initialize binding created by similar forms (IfStatement without an else clause in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;\
|
||||||
|
\
|
||||||
|
{\
|
||||||
|
function f() {}\
|
||||||
|
}if (true) function f() { }'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, undefined);
|
@ -0,0 +1,46 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-block-fn-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-no-else.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated (IfStatement without an else clause in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var updated;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'{\
|
||||||
|
function f() {\
|
||||||
|
return "first declaration";\
|
||||||
|
}\
|
||||||
|
}if (true) function f() { return "second declaration"; }updated = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof updated, 'function');
|
||||||
|
assert.sameValue(updated(), 'second declaration');
|
@ -0,0 +1,43 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-fn-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-no-else.template
|
||||||
|
/*---
|
||||||
|
description: Existing variable binding is not modified (IfStatement without an else clause in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;if (true) function f() { return "inner declaration"; }function f() {\
|
||||||
|
return "outer declaration";\
|
||||||
|
}'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init(), 'outer declaration');
|
@ -0,0 +1,46 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-fn-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-no-else.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated following evaluation (IfStatement without an else clause in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'if (true) function f() { return "inner declaration"; }after = f;\
|
||||||
|
\
|
||||||
|
function f() {\
|
||||||
|
return "outer declaration";\
|
||||||
|
}'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'inner declaration');
|
@ -0,0 +1,34 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-var-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-no-else.template
|
||||||
|
/*---
|
||||||
|
description: Existing variable binding is not modified (IfStatement without an else clause in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'var f = 123;\
|
||||||
|
init = f;if (true) function f() { }'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, 123);
|
@ -0,0 +1,45 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-var-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-no-else.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated following evaluation (IfStatement without an else clause in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'if (true) function f() { return "function declaration"; }after = f;\
|
||||||
|
\
|
||||||
|
var f = 123;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'function declaration');
|
||||||
|
|
@ -0,0 +1,46 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-no-else.template
|
||||||
|
/*---
|
||||||
|
description: Variable binding is initialized to `undefined` in outer scope (IfStatement without an else clause in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
i. If varEnvRec is a global Environment Record, then
|
||||||
|
[...]
|
||||||
|
ii. Else,
|
||||||
|
i. Let bindingExists be varEnvRec.HasBinding(F).
|
||||||
|
ii. If bindingExists is false, then
|
||||||
|
i. Perform ! varEnvRec.CreateMutableBinding(F, true).
|
||||||
|
ii. Perform ! varEnvRec.InitializeBinding(F, undefined).
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, changed;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;\
|
||||||
|
f = 123;\
|
||||||
|
changed = f;if (true) function f() { }'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, undefined, 'binding is initialized to `undefined`');
|
||||||
|
assert.sameValue(changed, 123, 'binding is mutable');
|
||||||
|
assert.throws(ReferenceError, function() {
|
||||||
|
f;
|
||||||
|
}, 'global binding is not created');
|
@ -0,0 +1,38 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-no-skip-param.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-no-else.template
|
||||||
|
/*---
|
||||||
|
description: Extension observed when there is a formal parameter with the same name (IfStatement without an else clause in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
ii. If replacing the FunctionDeclaration f with a VariableStatement that
|
||||||
|
has F as a BindingIdentifier would not produce any Early Errors for
|
||||||
|
body, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, after;
|
||||||
|
|
||||||
|
(function(f) {
|
||||||
|
eval(
|
||||||
|
'init = f;if (true) function f() { }after = f;'
|
||||||
|
);
|
||||||
|
}(123));
|
||||||
|
|
||||||
|
assert.sameValue(init, 123, 'binding is not initialized to `undefined`');
|
||||||
|
assert.sameValue(
|
||||||
|
typeof after, 'function', 'value is updated following evaluation'
|
||||||
|
);
|
@ -0,0 +1,37 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-skip-early-err.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-no-else.template
|
||||||
|
/*---
|
||||||
|
description: Extension not observed when creation of variable binding would produce an early error (IfStatement without an else clause in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
ii. If replacing the FunctionDeclaration f with a VariableStatement that
|
||||||
|
has F as a BindingIdentifier would not produce any Early Errors for
|
||||||
|
body, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'let f = 123;\
|
||||||
|
init = f;if (true) function f() { }after = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, 123, 'binding is not initialized to `undefined`');
|
||||||
|
assert.sameValue(after, 123, 'value is not updated following evaluation');
|
@ -0,0 +1,42 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-decl-no-else.template
|
||||||
|
/*---
|
||||||
|
description: Variable binding value is updated following evaluation (IfStatement without an else clause in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'if (true) function f() { return "declaration"; }after = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'declaration');
|
@ -0,0 +1,56 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-block-scoping.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-stmt-else-decl.template
|
||||||
|
/*---
|
||||||
|
description: A block-scoped binding is created (IfStatement with a declaration in the second statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
13.2.14 Runtime Semantics: BlockDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
4. For each element d in declarations do
|
||||||
|
a. For each element dn of the BoundNames of d do
|
||||||
|
i. If IsConstantDeclaration of d is true, then
|
||||||
|
[...]
|
||||||
|
ii. Else,
|
||||||
|
2. Perform ! envRec.CreateMutableBinding(dn, false).
|
||||||
|
|
||||||
|
b. If d is a GeneratorDeclaration production or a FunctionDeclaration
|
||||||
|
production, then
|
||||||
|
i. Let fn be the sole element of the BoundNames of d.
|
||||||
|
ii. Let fo be the result of performing InstantiateFunctionObject for
|
||||||
|
d with argument env.
|
||||||
|
iii. Perform envRec.InitializeBinding(fn, fo).
|
||||||
|
---*/
|
||||||
|
var initialBV, currentBV, varBinding;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'if (false) ; else function f() { initialBV = f; f = 123; currentBV = f; return "decl"; }varBinding = f;\
|
||||||
|
f();'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
initialBV(),
|
||||||
|
'decl',
|
||||||
|
'Block-scoped binding value is function object at execution time'
|
||||||
|
);
|
||||||
|
assert.sameValue(currentBV, 123, 'Block-scoped binding is mutable');
|
||||||
|
assert.sameValue(
|
||||||
|
varBinding(),
|
||||||
|
'decl',
|
||||||
|
'Block-scoped binding is independent of outer var-scoped binding'
|
||||||
|
);
|
@ -0,0 +1,37 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-block-fn-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-stmt-else-decl.template
|
||||||
|
/*---
|
||||||
|
description: Does not re-initialize binding created by similar forms (IfStatement with a declaration in the second statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;\
|
||||||
|
\
|
||||||
|
{\
|
||||||
|
function f() {}\
|
||||||
|
}if (false) ; else function f() { }'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, undefined);
|
@ -0,0 +1,46 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-block-fn-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-stmt-else-decl.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated (IfStatement with a declaration in the second statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var updated;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'{\
|
||||||
|
function f() {\
|
||||||
|
return "first declaration";\
|
||||||
|
}\
|
||||||
|
}if (false) ; else function f() { return "second declaration"; }updated = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof updated, 'function');
|
||||||
|
assert.sameValue(updated(), 'second declaration');
|
@ -0,0 +1,43 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-fn-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-stmt-else-decl.template
|
||||||
|
/*---
|
||||||
|
description: Existing variable binding is not modified (IfStatement with a declaration in the second statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;if (false) ; else function f() { return "inner declaration"; }function f() {\
|
||||||
|
return "outer declaration";\
|
||||||
|
}'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init(), 'outer declaration');
|
@ -0,0 +1,46 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-fn-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-stmt-else-decl.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated following evaluation (IfStatement with a declaration in the second statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'if (false) ; else function f() { return "inner declaration"; }after = f;\
|
||||||
|
\
|
||||||
|
function f() {\
|
||||||
|
return "outer declaration";\
|
||||||
|
}'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'inner declaration');
|
@ -0,0 +1,34 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-var-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-stmt-else-decl.template
|
||||||
|
/*---
|
||||||
|
description: Existing variable binding is not modified (IfStatement with a declaration in the second statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'var f = 123;\
|
||||||
|
init = f;if (false) ; else function f() { }'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, 123);
|
@ -0,0 +1,45 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-var-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-stmt-else-decl.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated following evaluation (IfStatement with a declaration in the second statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'if (false) ; else function f() { return "function declaration"; }after = f;\
|
||||||
|
\
|
||||||
|
var f = 123;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'function declaration');
|
||||||
|
|
@ -0,0 +1,46 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-stmt-else-decl.template
|
||||||
|
/*---
|
||||||
|
description: Variable binding is initialized to `undefined` in outer scope (IfStatement with a declaration in the second statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
i. If varEnvRec is a global Environment Record, then
|
||||||
|
[...]
|
||||||
|
ii. Else,
|
||||||
|
i. Let bindingExists be varEnvRec.HasBinding(F).
|
||||||
|
ii. If bindingExists is false, then
|
||||||
|
i. Perform ! varEnvRec.CreateMutableBinding(F, true).
|
||||||
|
ii. Perform ! varEnvRec.InitializeBinding(F, undefined).
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, changed;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;\
|
||||||
|
f = 123;\
|
||||||
|
changed = f;if (false) ; else function f() { }'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, undefined, 'binding is initialized to `undefined`');
|
||||||
|
assert.sameValue(changed, 123, 'binding is mutable');
|
||||||
|
assert.throws(ReferenceError, function() {
|
||||||
|
f;
|
||||||
|
}, 'global binding is not created');
|
@ -0,0 +1,38 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-no-skip-param.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-stmt-else-decl.template
|
||||||
|
/*---
|
||||||
|
description: Extension observed when there is a formal parameter with the same name (IfStatement with a declaration in the second statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
ii. If replacing the FunctionDeclaration f with a VariableStatement that
|
||||||
|
has F as a BindingIdentifier would not produce any Early Errors for
|
||||||
|
body, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, after;
|
||||||
|
|
||||||
|
(function(f) {
|
||||||
|
eval(
|
||||||
|
'init = f;if (false) ; else function f() { }after = f;'
|
||||||
|
);
|
||||||
|
}(123));
|
||||||
|
|
||||||
|
assert.sameValue(init, 123, 'binding is not initialized to `undefined`');
|
||||||
|
assert.sameValue(
|
||||||
|
typeof after, 'function', 'value is updated following evaluation'
|
||||||
|
);
|
@ -0,0 +1,37 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-skip-early-err.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-stmt-else-decl.template
|
||||||
|
/*---
|
||||||
|
description: Extension not observed when creation of variable binding would produce an early error (IfStatement with a declaration in the second statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
ii. If replacing the FunctionDeclaration f with a VariableStatement that
|
||||||
|
has F as a BindingIdentifier would not produce any Early Errors for
|
||||||
|
body, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'let f = 123;\
|
||||||
|
init = f;if (false) ; else function f() { }after = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, 123, 'binding is not initialized to `undefined`');
|
||||||
|
assert.sameValue(after, 123, 'value is not updated following evaluation');
|
@ -0,0 +1,42 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-if-stmt-else-decl.template
|
||||||
|
/*---
|
||||||
|
description: Variable binding value is updated following evaluation (IfStatement with a declaration in the second statement position in eval code)
|
||||||
|
esid: sec-functiondeclarations-in-ifstatement-statement-clauses
|
||||||
|
es6id: B.3.4
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
The following rules for IfStatement augment those in 13.6:
|
||||||
|
|
||||||
|
IfStatement[Yield, Return]:
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
|
||||||
|
if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
|
||||||
|
if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
|
||||||
|
|
||||||
|
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'if (false) ; else function f() { return "declaration"; }after = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'declaration');
|
@ -0,0 +1,51 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-block-scoping.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-case.template
|
||||||
|
/*---
|
||||||
|
description: A block-scoped binding is created (Function declaration in the `case` clause of a `switch` statement in eval code)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
13.2.14 Runtime Semantics: BlockDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
4. For each element d in declarations do
|
||||||
|
a. For each element dn of the BoundNames of d do
|
||||||
|
i. If IsConstantDeclaration of d is true, then
|
||||||
|
[...]
|
||||||
|
ii. Else,
|
||||||
|
2. Perform ! envRec.CreateMutableBinding(dn, false).
|
||||||
|
|
||||||
|
b. If d is a GeneratorDeclaration production or a FunctionDeclaration
|
||||||
|
production, then
|
||||||
|
i. Let fn be the sole element of the BoundNames of d.
|
||||||
|
ii. Let fo be the result of performing InstantiateFunctionObject for
|
||||||
|
d with argument env.
|
||||||
|
iii. Perform envRec.InitializeBinding(fn, fo).
|
||||||
|
---*/
|
||||||
|
var initialBV, currentBV, varBinding;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'switch (1) {' +
|
||||||
|
' case 1:' +
|
||||||
|
' function f() { initialBV = f; f = 123; currentBV = f; return "decl"; }' +
|
||||||
|
'}\
|
||||||
|
varBinding = f;\
|
||||||
|
f();'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
initialBV(),
|
||||||
|
'decl',
|
||||||
|
'Block-scoped binding value is function object at execution time'
|
||||||
|
);
|
||||||
|
assert.sameValue(currentBV, 123, 'Block-scoped binding is mutable');
|
||||||
|
assert.sameValue(
|
||||||
|
varBinding(),
|
||||||
|
'decl',
|
||||||
|
'Block-scoped binding is independent of outer var-scoped binding'
|
||||||
|
);
|
@ -0,0 +1,32 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-block-fn-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-case.template
|
||||||
|
/*---
|
||||||
|
description: Does not re-initialize binding created by similar forms (Function declaration in the `case` clause of a `switch` statement in eval code)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;\
|
||||||
|
\
|
||||||
|
{\
|
||||||
|
function f() {}\
|
||||||
|
}switch (1) {' +
|
||||||
|
' case 1:' +
|
||||||
|
' function f() { }' +
|
||||||
|
'}\
|
||||||
|
'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, undefined);
|
@ -0,0 +1,41 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-block-fn-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-case.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated (Function declaration in the `case` clause of a `switch` statement in eval code)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var updated;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'{\
|
||||||
|
function f() {\
|
||||||
|
return "first declaration";\
|
||||||
|
}\
|
||||||
|
}switch (1) {' +
|
||||||
|
' case 1:' +
|
||||||
|
' function f() { return "second declaration"; }' +
|
||||||
|
'}\
|
||||||
|
updated = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof updated, 'function');
|
||||||
|
assert.sameValue(updated(), 'second declaration');
|
@ -0,0 +1,38 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-fn-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-case.template
|
||||||
|
/*---
|
||||||
|
description: Existing variable binding is not modified (Function declaration in the `case` clause of a `switch` statement in eval code)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;switch (1) {' +
|
||||||
|
' case 1:' +
|
||||||
|
' function f() { return "inner declaration"; }' +
|
||||||
|
'}\
|
||||||
|
function f() {\
|
||||||
|
return "outer declaration";\
|
||||||
|
}'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init(), 'outer declaration');
|
@ -0,0 +1,41 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-fn-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-case.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated following evaluation (Function declaration in the `case` clause of a `switch` statement in eval code)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'switch (1) {' +
|
||||||
|
' case 1:' +
|
||||||
|
' function f() { return "inner declaration"; }' +
|
||||||
|
'}\
|
||||||
|
after = f;\
|
||||||
|
\
|
||||||
|
function f() {\
|
||||||
|
return "outer declaration";\
|
||||||
|
}'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'inner declaration');
|
@ -0,0 +1,29 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-var-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-case.template
|
||||||
|
/*---
|
||||||
|
description: Existing variable binding is not modified (Function declaration in the `case` clause of a `switch` statement in eval code)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'var f = 123;\
|
||||||
|
init = f;switch (1) {' +
|
||||||
|
' case 1:' +
|
||||||
|
' function f() { }' +
|
||||||
|
'}\
|
||||||
|
'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, 123);
|
@ -0,0 +1,40 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-var-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-case.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated following evaluation (Function declaration in the `case` clause of a `switch` statement in eval code)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'switch (1) {' +
|
||||||
|
' case 1:' +
|
||||||
|
' function f() { return "function declaration"; }' +
|
||||||
|
'}\
|
||||||
|
after = f;\
|
||||||
|
\
|
||||||
|
var f = 123;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'function declaration');
|
||||||
|
|
@ -0,0 +1,41 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-case.template
|
||||||
|
/*---
|
||||||
|
description: Variable binding is initialized to `undefined` in outer scope (Function declaration in the `case` clause of a `switch` statement in eval code)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
i. If varEnvRec is a global Environment Record, then
|
||||||
|
[...]
|
||||||
|
ii. Else,
|
||||||
|
i. Let bindingExists be varEnvRec.HasBinding(F).
|
||||||
|
ii. If bindingExists is false, then
|
||||||
|
i. Perform ! varEnvRec.CreateMutableBinding(F, true).
|
||||||
|
ii. Perform ! varEnvRec.InitializeBinding(F, undefined).
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, changed;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;\
|
||||||
|
f = 123;\
|
||||||
|
changed = f;switch (1) {' +
|
||||||
|
' case 1:' +
|
||||||
|
' function f() { }' +
|
||||||
|
'}\
|
||||||
|
'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, undefined, 'binding is initialized to `undefined`');
|
||||||
|
assert.sameValue(changed, 123, 'binding is mutable');
|
||||||
|
assert.throws(ReferenceError, function() {
|
||||||
|
f;
|
||||||
|
}, 'global binding is not created');
|
@ -0,0 +1,33 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-no-skip-param.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-case.template
|
||||||
|
/*---
|
||||||
|
description: Extension observed when there is a formal parameter with the same name (Function declaration in the `case` clause of a `switch` statement in eval code)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
ii. If replacing the FunctionDeclaration f with a VariableStatement that
|
||||||
|
has F as a BindingIdentifier would not produce any Early Errors for
|
||||||
|
body, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, after;
|
||||||
|
|
||||||
|
(function(f) {
|
||||||
|
eval(
|
||||||
|
'init = f;switch (1) {' +
|
||||||
|
' case 1:' +
|
||||||
|
' function f() { }' +
|
||||||
|
'}\
|
||||||
|
after = f;'
|
||||||
|
);
|
||||||
|
}(123));
|
||||||
|
|
||||||
|
assert.sameValue(init, 123, 'binding is not initialized to `undefined`');
|
||||||
|
assert.sameValue(
|
||||||
|
typeof after, 'function', 'value is updated following evaluation'
|
||||||
|
);
|
@ -0,0 +1,32 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-skip-early-err.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-case.template
|
||||||
|
/*---
|
||||||
|
description: Extension not observed when creation of variable binding would produce an early error (Function declaration in the `case` clause of a `switch` statement in eval code)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
ii. If replacing the FunctionDeclaration f with a VariableStatement that
|
||||||
|
has F as a BindingIdentifier would not produce any Early Errors for
|
||||||
|
body, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'let f = 123;\
|
||||||
|
init = f;switch (1) {' +
|
||||||
|
' case 1:' +
|
||||||
|
' function f() { }' +
|
||||||
|
'}\
|
||||||
|
after = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, 123, 'binding is not initialized to `undefined`');
|
||||||
|
assert.sameValue(after, 123, 'value is not updated following evaluation');
|
@ -0,0 +1,37 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-case.template
|
||||||
|
/*---
|
||||||
|
description: Variable binding value is updated following evaluation (Function declaration in the `case` clause of a `switch` statement in eval code)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'switch (1) {' +
|
||||||
|
' case 1:' +
|
||||||
|
' function f() { return "declaration"; }' +
|
||||||
|
'}\
|
||||||
|
after = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'declaration');
|
@ -0,0 +1,51 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-block-scoping.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-dflt.template
|
||||||
|
/*---
|
||||||
|
description: A block-scoped binding is created (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
13.2.14 Runtime Semantics: BlockDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
4. For each element d in declarations do
|
||||||
|
a. For each element dn of the BoundNames of d do
|
||||||
|
i. If IsConstantDeclaration of d is true, then
|
||||||
|
[...]
|
||||||
|
ii. Else,
|
||||||
|
2. Perform ! envRec.CreateMutableBinding(dn, false).
|
||||||
|
|
||||||
|
b. If d is a GeneratorDeclaration production or a FunctionDeclaration
|
||||||
|
production, then
|
||||||
|
i. Let fn be the sole element of the BoundNames of d.
|
||||||
|
ii. Let fo be the result of performing InstantiateFunctionObject for
|
||||||
|
d with argument env.
|
||||||
|
iii. Perform envRec.InitializeBinding(fn, fo).
|
||||||
|
---*/
|
||||||
|
var initialBV, currentBV, varBinding;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'switch (1) {' +
|
||||||
|
' default:' +
|
||||||
|
' function f() { initialBV = f; f = 123; currentBV = f; return "decl"; }' +
|
||||||
|
'}\
|
||||||
|
varBinding = f;\
|
||||||
|
f();'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
initialBV(),
|
||||||
|
'decl',
|
||||||
|
'Block-scoped binding value is function object at execution time'
|
||||||
|
);
|
||||||
|
assert.sameValue(currentBV, 123, 'Block-scoped binding is mutable');
|
||||||
|
assert.sameValue(
|
||||||
|
varBinding(),
|
||||||
|
'decl',
|
||||||
|
'Block-scoped binding is independent of outer var-scoped binding'
|
||||||
|
);
|
@ -0,0 +1,32 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-block-fn-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-dflt.template
|
||||||
|
/*---
|
||||||
|
description: Does not re-initialize binding created by similar forms (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;\
|
||||||
|
\
|
||||||
|
{\
|
||||||
|
function f() {}\
|
||||||
|
}switch (1) {' +
|
||||||
|
' default:' +
|
||||||
|
' function f() { }' +
|
||||||
|
'}\
|
||||||
|
'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, undefined);
|
@ -0,0 +1,41 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-block-fn-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-dflt.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var updated;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'{\
|
||||||
|
function f() {\
|
||||||
|
return "first declaration";\
|
||||||
|
}\
|
||||||
|
}switch (1) {' +
|
||||||
|
' default:' +
|
||||||
|
' function f() { return "second declaration"; }' +
|
||||||
|
'}\
|
||||||
|
updated = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof updated, 'function');
|
||||||
|
assert.sameValue(updated(), 'second declaration');
|
@ -0,0 +1,38 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-fn-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-dflt.template
|
||||||
|
/*---
|
||||||
|
description: Existing variable binding is not modified (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;switch (1) {' +
|
||||||
|
' default:' +
|
||||||
|
' function f() { return "inner declaration"; }' +
|
||||||
|
'}\
|
||||||
|
function f() {\
|
||||||
|
return "outer declaration";\
|
||||||
|
}'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init(), 'outer declaration');
|
@ -0,0 +1,41 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-fn-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-dflt.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated following evaluation (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'switch (1) {' +
|
||||||
|
' default:' +
|
||||||
|
' function f() { return "inner declaration"; }' +
|
||||||
|
'}\
|
||||||
|
after = f;\
|
||||||
|
\
|
||||||
|
function f() {\
|
||||||
|
return "outer declaration";\
|
||||||
|
}'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'inner declaration');
|
@ -0,0 +1,29 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-var-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-dflt.template
|
||||||
|
/*---
|
||||||
|
description: Existing variable binding is not modified (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'var f = 123;\
|
||||||
|
init = f;switch (1) {' +
|
||||||
|
' default:' +
|
||||||
|
' function f() { }' +
|
||||||
|
'}\
|
||||||
|
'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, 123);
|
@ -0,0 +1,40 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-exsting-var-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-dflt.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated following evaluation (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'switch (1) {' +
|
||||||
|
' default:' +
|
||||||
|
' function f() { return "function declaration"; }' +
|
||||||
|
'}\
|
||||||
|
after = f;\
|
||||||
|
\
|
||||||
|
var f = 123;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'function declaration');
|
||||||
|
|
@ -0,0 +1,41 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-init.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-dflt.template
|
||||||
|
/*---
|
||||||
|
description: Variable binding is initialized to `undefined` in outer scope (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
i. If varEnvRec is a global Environment Record, then
|
||||||
|
[...]
|
||||||
|
ii. Else,
|
||||||
|
i. Let bindingExists be varEnvRec.HasBinding(F).
|
||||||
|
ii. If bindingExists is false, then
|
||||||
|
i. Perform ! varEnvRec.CreateMutableBinding(F, true).
|
||||||
|
ii. Perform ! varEnvRec.InitializeBinding(F, undefined).
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, changed;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'init = f;\
|
||||||
|
f = 123;\
|
||||||
|
changed = f;switch (1) {' +
|
||||||
|
' default:' +
|
||||||
|
' function f() { }' +
|
||||||
|
'}\
|
||||||
|
'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, undefined, 'binding is initialized to `undefined`');
|
||||||
|
assert.sameValue(changed, 123, 'binding is mutable');
|
||||||
|
assert.throws(ReferenceError, function() {
|
||||||
|
f;
|
||||||
|
}, 'global binding is not created');
|
@ -0,0 +1,33 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-no-skip-param.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-dflt.template
|
||||||
|
/*---
|
||||||
|
description: Extension observed when there is a formal parameter with the same name (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
ii. If replacing the FunctionDeclaration f with a VariableStatement that
|
||||||
|
has F as a BindingIdentifier would not produce any Early Errors for
|
||||||
|
body, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, after;
|
||||||
|
|
||||||
|
(function(f) {
|
||||||
|
eval(
|
||||||
|
'init = f;switch (1) {' +
|
||||||
|
' default:' +
|
||||||
|
' function f() { }' +
|
||||||
|
'}\
|
||||||
|
after = f;'
|
||||||
|
);
|
||||||
|
}(123));
|
||||||
|
|
||||||
|
assert.sameValue(init, 123, 'binding is not initialized to `undefined`');
|
||||||
|
assert.sameValue(
|
||||||
|
typeof after, 'function', 'value is updated following evaluation'
|
||||||
|
);
|
@ -0,0 +1,32 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-skip-early-err.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-dflt.template
|
||||||
|
/*---
|
||||||
|
description: Extension not observed when creation of variable binding would produce an early error (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
ii. If replacing the FunctionDeclaration f with a VariableStatement that
|
||||||
|
has F as a BindingIdentifier would not produce any Early Errors for
|
||||||
|
body, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
var init, after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'let f = 123;\
|
||||||
|
init = f;switch (1) {' +
|
||||||
|
' default:' +
|
||||||
|
' function f() { }' +
|
||||||
|
'}\
|
||||||
|
after = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(init, 123, 'binding is not initialized to `undefined`');
|
||||||
|
assert.sameValue(after, 123, 'value is not updated following evaluation');
|
@ -0,0 +1,37 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-func-update.case
|
||||||
|
// - src/annex-b-fns/eval-func/direct-switch-dflt.template
|
||||||
|
/*---
|
||||||
|
description: Variable binding value is updated following evaluation (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
var after;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
eval(
|
||||||
|
'switch (1) {' +
|
||||||
|
' default:' +
|
||||||
|
' function f() { return "declaration"; }' +
|
||||||
|
'}\
|
||||||
|
after = f;'
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
assert.sameValue(typeof after, 'function');
|
||||||
|
assert.sameValue(after(), 'declaration');
|
@ -0,0 +1,45 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-global-block-scoping.case
|
||||||
|
// - src/annex-b-fns/eval-global/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: A block-scoped binding is created (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
13.2.14 Runtime Semantics: BlockDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
4. For each element d in declarations do
|
||||||
|
a. For each element dn of the BoundNames of d do
|
||||||
|
i. If IsConstantDeclaration of d is true, then
|
||||||
|
[...]
|
||||||
|
ii. Else,
|
||||||
|
2. Perform ! envRec.CreateMutableBinding(dn, false).
|
||||||
|
|
||||||
|
b. If d is a GeneratorDeclaration production or a FunctionDeclaration
|
||||||
|
production, then
|
||||||
|
i. Let fn be the sole element of the BoundNames of d.
|
||||||
|
ii. Let fo be the result of performing InstantiateFunctionObject for
|
||||||
|
d with argument env.
|
||||||
|
iii. Perform envRec.InitializeBinding(fn, fo).
|
||||||
|
---*/
|
||||||
|
var initialBV, currentBV;
|
||||||
|
|
||||||
|
eval(
|
||||||
|
'{ function f() { initialBV = f; f = 123; currentBV = f; return "decl"; } }'
|
||||||
|
);
|
||||||
|
|
||||||
|
f();
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
initialBV(),
|
||||||
|
'decl',
|
||||||
|
'Block-scoped binding value is function object at execution time'
|
||||||
|
);
|
||||||
|
assert.sameValue(currentBV, 123, 'Block-scoped binding is mutable');
|
||||||
|
assert.sameValue(
|
||||||
|
f(),
|
||||||
|
'decl',
|
||||||
|
'Block-scoped binding is independent of outer var-scoped binding'
|
||||||
|
);
|
@ -0,0 +1,23 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-global-exsting-block-fn-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-global/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Does not re-initialize binding created by similar forms (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
eval(
|
||||||
|
'assert.sameValue(f, undefined);\
|
||||||
|
\
|
||||||
|
{\
|
||||||
|
function f() {}\
|
||||||
|
}{ function f() { } }'
|
||||||
|
);
|
@ -0,0 +1,35 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-global-exsting-block-fn-update.case
|
||||||
|
// - src/annex-b-fns/eval-global/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
{
|
||||||
|
function f() {
|
||||||
|
return 'first declaration';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
eval(
|
||||||
|
'{ function f() { return "second declaration"; } }'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(typeof f, 'function');
|
||||||
|
assert.sameValue(f(), 'second declaration');
|
@ -0,0 +1,21 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-global-exsting-fn-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-global/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Existing variable binding is not modified (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
eval(
|
||||||
|
'assert.sameValue(f(), "outer declaration");{ function f() { return "inner declaration"; } }function f() {\
|
||||||
|
return "outer declaration";\
|
||||||
|
}'
|
||||||
|
);
|
@ -0,0 +1,32 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-global-exsting-fn-update.case
|
||||||
|
// - src/annex-b-fns/eval-global/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated following evaluation (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
eval(
|
||||||
|
'{ function f() { return "inner declaration"; } }assert.sameValue(typeof f, "function");\
|
||||||
|
assert.sameValue(f(), "inner declaration");\
|
||||||
|
\
|
||||||
|
function f() {\
|
||||||
|
return "outer declaration";\
|
||||||
|
}'
|
||||||
|
);
|
@ -0,0 +1,43 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-global-exsting-global-init.case
|
||||||
|
// - src/annex-b-fns/eval-global/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Variable binding is set to `undefined` (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
includes: [fnGlobalObject.js, propertyHelper.js]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
i. If varEnvRec is a global Environment Record, then
|
||||||
|
i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true).
|
||||||
|
[...]
|
||||||
|
|
||||||
|
8.1.1.4.18 CreateGlobalFunctionBinding
|
||||||
|
|
||||||
|
[...]
|
||||||
|
5. If existingProp is undefined or existingProp.[[Configurable]] is true,
|
||||||
|
then
|
||||||
|
[...]
|
||||||
|
6. Else,
|
||||||
|
a. Let desc be the PropertyDescriptor{[[Value]]: V }.
|
||||||
|
[...]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
Object.defineProperty(fnGlobalObject(), 'f', {
|
||||||
|
value: 'x',
|
||||||
|
enumerable: true,
|
||||||
|
writable: true,
|
||||||
|
configurable: false
|
||||||
|
});
|
||||||
|
|
||||||
|
eval(
|
||||||
|
'var global = fnGlobalObject();\
|
||||||
|
assert.sameValue(f, undefined, "binding is initialized to `undefined`");\
|
||||||
|
\
|
||||||
|
verifyEnumerable(global, "f");\
|
||||||
|
verifyWritable(global, "f");\
|
||||||
|
verifyNotConfigurable(global, "f");{ function f() { } }'
|
||||||
|
);
|
@ -0,0 +1,38 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-global-exsting-global-update.case
|
||||||
|
// - src/annex-b-fns/eval-global/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated following evaluation (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
includes: [fnGlobalObject.js]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
|
||||||
|
---*/
|
||||||
|
Object.defineProperty(fnGlobalObject(), 'f', {
|
||||||
|
value: function() { return 'Another function'; },
|
||||||
|
enumerable: true,
|
||||||
|
writable: true,
|
||||||
|
configurable: false
|
||||||
|
});
|
||||||
|
|
||||||
|
eval(
|
||||||
|
'{ function f() { return "function declaration"; } }'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(typeof f, 'function');
|
||||||
|
assert.sameValue(f(), 'function declaration');
|
@ -0,0 +1,20 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-global-exsting-var-no-init.case
|
||||||
|
// - src/annex-b-fns/eval-global/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Existing variable binding is not modified (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
a. If declaredFunctionOrVarNames does not contain F, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
eval(
|
||||||
|
'var f = 123;\
|
||||||
|
assert.sameValue(f, 123);{ function f() { } }'
|
||||||
|
);
|
@ -0,0 +1,32 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-global-exsting-var-update.case
|
||||||
|
// - src/annex-b-fns/eval-global/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Variable-scoped binding is updated following evaluation (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
eval(
|
||||||
|
'{ function f() { return "function declaration"; } }'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(typeof f, 'function');
|
||||||
|
assert.sameValue(f(), 'function declaration');
|
||||||
|
|
||||||
|
var f = 123;
|
@ -0,0 +1,28 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-global-init.case
|
||||||
|
// - src/annex-b-fns/eval-global/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Variable binding is initialized to `undefined` in outer scope (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
includes: [fnGlobalObject.js, propertyHelper.js]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
i. If varEnvRec is a global Environment Record, then
|
||||||
|
i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true).
|
||||||
|
[...]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
eval(
|
||||||
|
'var global = fnGlobalObject();\
|
||||||
|
assert.sameValue(f, undefined, "binding is initialized to `undefined`");\
|
||||||
|
\
|
||||||
|
verifyEnumerable(global, "f");\
|
||||||
|
verifyWritable(global, "f");\
|
||||||
|
verifyConfigurable(global, "f");\
|
||||||
|
{ function f() { } }'
|
||||||
|
);
|
@ -0,0 +1,22 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-global-skip-early-err.case
|
||||||
|
// - src/annex-b-fns/eval-global/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Extension not observed when creation of variable binding would produce an early error (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
ii. If replacing the FunctionDeclaration f with a VariableStatement that
|
||||||
|
has F as a BindingIdentifier would not produce any Early Errors for
|
||||||
|
body, then
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
eval(
|
||||||
|
'let f = 123;\
|
||||||
|
assert.sameValue(f, 123, "binding is not initialized to `undefined`");{ function f() { } }assert.sameValue(f, 123, "value is not updated following evaluation");'
|
||||||
|
);
|
@ -0,0 +1,28 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/annex-b-fns/eval-global-update.case
|
||||||
|
// - src/annex-b-fns/eval-global/direct-block.template
|
||||||
|
/*---
|
||||||
|
description: Variable binding value is updated following evaluation (Block statement in eval code containing a function declaration)
|
||||||
|
esid: sec-web-compat-evaldeclarationinstantiation
|
||||||
|
es6id: B.3.3.3
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: >
|
||||||
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
b. When the FunctionDeclaration f is evaluated, perform the following steps
|
||||||
|
in place of the FunctionDeclaration Evaluation algorithm provided in
|
||||||
|
14.1.21:
|
||||||
|
i. Let genv be the running execution context's VariableEnvironment.
|
||||||
|
ii. Let genvRec be genv's EnvironmentRecord.
|
||||||
|
iii. Let benv be the running execution context's LexicalEnvironment.
|
||||||
|
iv. Let benvRec be benv's EnvironmentRecord.
|
||||||
|
v. Let fobj be ! benvRec.GetBindingValue(F, false).
|
||||||
|
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
|
||||||
|
vii. Return NormalCompletion(empty).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
eval(
|
||||||
|
'{ function f() { return "declaration"; } }assert.sameValue(typeof f, "function");\
|
||||||
|
assert.sameValue(f(), "declaration");'
|
||||||
|
);
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user