Files
ladybird/Libraries/LibJS/Parser.cpp
Andreas Kling 40430d6087 LibJS: Detect direct eval calls in parse_call_expression()
The parser previously detected direct eval() calls at the end of
parse_expression(), by checking if the final expression was a
CallExpression with "eval" as the callee. This missed cases where
eval() appeared as a subexpression, e.g. `eval(code) | 0`, since
the final expression would be a BinaryExpression, not a
CallExpression.

Move the detection into parse_call_expression() where the
CallExpression is actually created. This ensures we always set the
contains_direct_call_to_eval flag regardless of surrounding
operators, so local variables are correctly placed in the
declarative environment where eval'd code can find them.
2026-02-07 18:05:41 +01:00

236 KiB