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 <Joseph Pecoraro> on 2016-09-22
Reviewed by Saam Barati.
JSTests:
- stress/es6-default-parameters.js:
Add our own tests for function lengths with default parameters.
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):
(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):
(JSC::SyntaxChecker::createFunctionMetadata):
- runtime/Executable.h:
- runtime/JSFunction.cpp:
(JSC::JSFunction::createBuiltinFunction):
(JSC::JSFunction::reifyLength):