mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:48:12 +00:00
LibJS: Strict mode assignment to 'eval' & 'arguments' is a syntax error
This commit is contained in:
parent
786722149b
commit
cbe506020b
1 changed files with 10 additions and 0 deletions
|
@ -816,6 +816,16 @@ NonnullRefPtr<Expression> Parser::parse_secondary_expression(NonnullRefPtr<Expre
|
|||
syntax_error("Invalid left-hand side in assignment");
|
||||
return create_ast_node<ErrorExpression>();
|
||||
}
|
||||
if (m_parser_state.m_strict_mode && lhs->is_identifier()) {
|
||||
auto name = static_cast<const Identifier&>(*lhs).string();
|
||||
if (name == "eval" || name == "arguments") {
|
||||
syntax_error(
|
||||
String::format("'%s' cannot be assigned to in strict mode code", name.characters()),
|
||||
m_parser_state.m_current_token.line_number(),
|
||||
m_parser_state.m_current_token.line_column()
|
||||
);
|
||||
}
|
||||
}
|
||||
return create_ast_node<AssignmentExpression>(AssignmentOp::Assignment, move(lhs), parse_expression(min_precedence, associativity));
|
||||
case TokenType::Period:
|
||||
consume();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue