diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-07-10 22:48:25 +0430 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-07-11 21:41:54 +0100 |
commit | b5b84029ab17996fb9483f99346a1d08bfa2d175 (patch) | |
tree | 039780918bfd1bf44e2ec5ec9754ec17432c4853 | |
parent | 0f35912bd789e37b8e7193ffc88827fd1f2fcfec (diff) | |
download | serenity-b5b84029ab17996fb9483f99346a1d08bfa2d175.zip |
LibJS: Treat default parameter values as being in function context
e.g. `new.target` should be permitted in
`function foo(x = new.target) {}`.
-rw-r--r-- | Userland/Libraries/LibJS/Parser.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Parser.cpp b/Userland/Libraries/LibJS/Parser.cpp index 44d6775786..846693cf93 100644 --- a/Userland/Libraries/LibJS/Parser.cpp +++ b/Userland/Libraries/LibJS/Parser.cpp @@ -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); |