1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:57:35 +00:00

JSSpecCompiler: Properly parse function calls with zero arguments

We cannot handle them normally since we need text between parenthesis to
be a valid expression. As a workaround, we now push an artificial value
to stack to act as an argument (it'll be later removed during function
call canonicalization).
This commit is contained in:
Dan Klishch 2024-01-16 00:21:59 -05:00 committed by Andrew Kaster
parent 14ee25b8ba
commit 33b36476d9
4 changed files with 50 additions and 1 deletions

View file

@ -25,6 +25,11 @@ RecursionDecision FunctionCallCanonicalizationPass::on_entry(Tree tree)
}
arguments.append(current_tree);
if (arguments[0] == zero_argument_function_call) {
VERIFY(arguments.size() == 1);
arguments.clear();
}
replace_current_node_with(make_ref_counted<FunctionCall>(binary_operation->m_left, move(arguments)));
}
}