Browse Source

Allow `NewExpression` without arguments (#1505)

* Allow `NewExpression` without arguments

* Fix arrow functions to not be constructable
pull/1506/head
raskad 3 years ago committed by GitHub
parent
commit
42686de9f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      boa/src/syntax/ast/node/declaration/arrow_function_decl/mod.rs
  2. 7
      boa/src/syntax/parser/expression/left_hand_side/member.rs

2
boa/src/syntax/ast/node/declaration/arrow_function_decl/mod.rs

@ -77,7 +77,7 @@ impl Executable for ArrowFunctionDecl {
"",
self.params().to_vec(),
self.body().to_vec(),
FunctionFlags::CONSTRUCTABLE | FunctionFlags::LEXICAL_THIS_MODE,
FunctionFlags::LEXICAL_THIS_MODE,
)
}
}

7
boa/src/syntax/parser/expression/left_hand_side/member.rs

@ -69,7 +69,12 @@ where
{
let _ = cursor.next().expect("new keyword disappeared");
let lhs = self.parse(cursor)?;
let args = Arguments::new(self.allow_yield, self.allow_await).parse(cursor)?;
let args = match cursor.peek(0)? {
Some(next) if next.kind() == &TokenKind::Punctuator(Punctuator::OpenParen) => {
Arguments::new(self.allow_yield, self.allow_await).parse(cursor)?
}
_ => Box::new([]),
};
let call_node = Call::new(lhs, args);
Node::from(New::from(call_node))

Loading…
Cancel
Save