LibJS: Treat default parameter values as being in function context

e.g. `new.target` should be permitted in
`function foo(x = new.target) {}`.
This commit is contained in:
Ali Mohammad Pur 2021-07-10 22:48:25 +04:30 committed by Linus Groh
parent 0f35912bd7
commit b5b84029ab
Notes: sideshowbarker 2024-07-18 09:15:49 +09:00

View file

@ -1570,6 +1570,7 @@ Vector<FunctionNode::Parameter> Parser::parse_formal_parameters(int& function_le
RefPtr<Expression> default_value;
if (match(TokenType::Equals)) {
consume();
TemporaryChange change(m_state.in_function_context, true);
has_default_parameter = true;
function_length = parameters.size();
default_value = parse_expression(2);