test262: Function length should be number of parameters before parameters with default values
https://bugs.webkit.org/show_bug.cgi?id=162377
Patch by Joseph Pecoraro <pecoraro@apple.com> on 2016-09-22
Reviewed by Saam Barati.
JSTests:
* stress/es6-default-parameters.js:
Add our own tests for function lengths with default parameters.
* test262.yaml:
We now pass all dflt-length tests.
Source/JavaScriptCore:
https://tc39.github.io/ecma262/#sec-function-definitions-static-semantics-expectedargumentcount
> NOTE: The ExpectedArgumentCount of a FormalParameterList is the number of
> FormalParameters to the left of either the rest parameter or the first
> FormalParameter with an Initializer. A FormalParameter without an
> initializer is allowed after the first parameter with an initializer
> but such parameters are considered to be optional with undefined as
> their default value.
Alongside the parameterCount value, maintain a separate count,
functionLength, which will be the count before seeing a rest parameter
or parameter with a default value. This will be the function's length.
* bytecode/UnlinkedCodeBlock.h:
* bytecode/UnlinkedFunctionExecutable.cpp:
(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
* bytecode/UnlinkedFunctionExecutable.h:
* parser/ASTBuilder.h:
(JSC::ASTBuilder::createFunctionMetadata):
* parser/Nodes.cpp:
(JSC::FunctionMetadataNode::FunctionMetadataNode):
* parser/Nodes.h:
* parser/Parser.cpp:
(JSC::Parser<LexerType>::isArrowFunctionParameters):
(JSC::Parser<LexerType>::parseGeneratorFunctionSourceElements):
(JSC::Parser<LexerType>::parseFormalParameters):
(JSC::Parser<LexerType>::parseFunctionBody):
(JSC::Parser<LexerType>::parseFunctionParameters):
(JSC::Parser<LexerType>::parseFunctionInfo):
* parser/Parser.h:
* parser/ParserFunctionInfo.h:
* parser/SourceProviderCacheItem.h:
(JSC::SourceProviderCacheItem::SourceProviderCacheItem):
* parser/SyntaxChecker.h:
(JSC::SyntaxChecker::createFunctionMetadata):
* runtime/Executable.h:
* runtime/JSFunction.cpp:
(JSC::JSFunction::createBuiltinFunction):
(JSC::JSFunction::reifyLength):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@206268 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed