1
Fork 0
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:
davidot 2021-07-12 01:32:24 +02:00 committed by Andreas Kling
parent 697882a7ad
commit a6263150be

View file

@ -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();