Destructuring parameters are evaluated in the wrong scope
authorsbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Mar 2016 08:59:01 +0000 (08:59 +0000)
committersbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Mar 2016 08:59:01 +0000 (08:59 +0000)
commit62c272ea142fff365bd25911d60957ae0e71d2ad
tree802ead8f1e490dce4f3fb9630416c3559cfd1d39
parent3e4f2f955da83d69c3ceb989d425651bdee5fc27
Destructuring parameters are evaluated in the wrong scope
https://bugs.webkit.org/show_bug.cgi?id=155454

Reviewed by Geoffrey Garen.

This patch makes our engine compatible with how parameter
lists are evaluated in ES6. A parameter list that contains
a rest parameter, any destructuring patterns, or default parameter values,
is classified as being non-simple. Non-simple parameter lists
must get their own scope to live in, and the variables in the
scope are under TDZ. This means that functions evaluated in the
parameter list don't have access to variables inside the function
body. Also, non-simple parameter lists get the strict-mode arguments object.

* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::~BytecodeGenerator):
(JSC::BytecodeGenerator::initializeDefaultParameterValuesAndSetupFunctionScopeStack):
(JSC::BytecodeGenerator::initializeArrowFunctionContextScopeIfNeeded):
* bytecompiler/BytecodeGenerator.h:
* parser/Nodes.h:
(JSC::FunctionParameters::size):
(JSC::FunctionParameters::at):
(JSC::FunctionParameters::append):
(JSC::FunctionParameters::hasDefaultParameterValues): Deleted.
* tests/es6.yaml:
* tests/stress/parameter-scoping.js: Added.
(assert):
(test):
(test.foo):
(test.):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198206 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
Source/JavaScriptCore/parser/Nodes.h
Source/JavaScriptCore/tests/es6.yaml
Source/JavaScriptCore/tests/stress/parameter-scoping.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/v8-parameter-scoping.js [new file with mode: 0644]