mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 20:17:41 +00:00
LibJS: Disallow 'with' statement in strict mode
This commit is contained in:
parent
42b1b36eb4
commit
3ac7fb9f6c
2 changed files with 6 additions and 0 deletions
|
@ -328,6 +328,8 @@ NonnullRefPtr<Statement> Parser::parse_statement()
|
||||||
case TokenType::While:
|
case TokenType::While:
|
||||||
return parse_while_statement();
|
return parse_while_statement();
|
||||||
case TokenType::With:
|
case TokenType::With:
|
||||||
|
if (m_parser_state.m_strict_mode)
|
||||||
|
syntax_error("'with' statement not allowed in strict mode");
|
||||||
return parse_with_statement();
|
return parse_with_statement();
|
||||||
case TokenType::Debugger:
|
case TokenType::Debugger:
|
||||||
return parse_debugger_statement();
|
return parse_debugger_statement();
|
||||||
|
|
|
@ -18,3 +18,7 @@ test("basic with statement functionality", () => {
|
||||||
|
|
||||||
expect(bar).toBe(99);
|
expect(bar).toBe(99);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("syntax error in strict mode", () => {
|
||||||
|
expect("'use strict'; with (foo) {}").not.toEval();
|
||||||
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue