mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibJS: Disallow unqualified deletes in strict mode
This commit is contained in:
parent
697882a7ad
commit
a6263150be
Notes:
sideshowbarker
2024-07-18 08:39:43 +09:00
Author: https://github.com/davidot
Commit: a6263150be
Pull-request: https://github.com/SerenityOS/serenity/pull/8667
Reviewed-by: https://github.com/IdanHo
Reviewed-by: https://github.com/linusg
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