1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 03:35:09 +00:00

LibJS: `save_state()' before creating a RulePosition

Fixes #4617.
This commit is contained in:
AnotherTest 2020-12-29 08:42:02 +03:30 committed by Andreas Kling
parent 620b73b3d5
commit d0363bca01
2 changed files with 14 additions and 3 deletions

View file

@ -361,12 +361,13 @@ NonnullRefPtr<Statement> Parser::parse_statement()
RefPtr<FunctionExpression> Parser::try_parse_arrow_function_expression(bool expect_parens)
{
auto rule_start = push_start();
save_state();
m_parser_state.m_var_scopes.append(NonnullRefPtrVector<VariableDeclaration>());
auto rule_start = push_start();
ArmedScopeGuard state_rollback_guard = [&] {
m_parser_state.m_var_scopes.take_last();
rule_start.disable();
load_state();
};
@ -442,9 +443,10 @@ RefPtr<FunctionExpression> Parser::try_parse_arrow_function_expression(bool expe
RefPtr<Statement> Parser::try_parse_labelled_statement()
{
auto rule_start = push_start();
save_state();
auto rule_start = push_start();
ArmedScopeGuard state_rollback_guard = [&] {
rule_start.disable();
load_state();
};
@ -466,9 +468,10 @@ RefPtr<Statement> Parser::try_parse_labelled_statement()
RefPtr<MetaProperty> Parser::try_parse_new_target_expression()
{
auto rule_start = push_start();
save_state();
auto rule_start = push_start();
ArmedScopeGuard state_rollback_guard = [&] {
rule_start.disable();
load_state();
};