mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:38:12 +00:00
LibJS: Disallow unqualified deletes in strict mode
This commit is contained in:
parent
697882a7ad
commit
a6263150be
1 changed files with 8 additions and 2 deletions
|
@ -923,9 +923,15 @@ NonnullRefPtr<Expression> Parser::parse_unary_prefixed_expression()
|
|||
case TokenType::Void:
|
||||
consume();
|
||||
return create_ast_node<UnaryExpression>({ m_state.current_token.filename(), rule_start.position(), position() }, UnaryOp::Void, parse_expression(precedence, associativity));
|
||||
case TokenType::Delete:
|
||||
case TokenType::Delete: {
|
||||
consume();
|
||||
return create_ast_node<UnaryExpression>({ m_state.current_token.filename(), rule_start.position(), position() }, UnaryOp::Delete, parse_expression(precedence, associativity));
|
||||
auto rhs_start = position();
|
||||
auto rhs = parse_expression(precedence, associativity);
|
||||
if (is<Identifier>(*rhs) && m_state.strict_mode) {
|
||||
syntax_error("Delete of an unqualified identifier in strict mode.", rhs_start);
|
||||
}
|
||||
return create_ast_node<UnaryExpression>({ m_state.current_token.filename(), rule_start.position(), position() }, UnaryOp::Delete, move(rhs));
|
||||
}
|
||||
default:
|
||||
expected("primary expression");
|
||||
consume();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue