mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibJS: Parse RegExp literals at AST creation time, not execution time
The spec requires that invalid RegExp literals must cause a Syntax Error before the JavaScript is executed. See: https://tc39.es/ecma262/#sec-patterns-static-semantics-early-errors This is explicitly tested in the RegExp/property-escapes test262 tests. For example, see unsupported-property-Line_Break.js: $DONOTEVALUATE(); /\p{Line_Break}/u; That RegExp literal is invalid because Line_Break is not a supported Unicode property. $DONOTEVALUATE() just throws an exception when it is executed. The test expects that this file will fail to be parsed. Note that RegExp patterns can still be parsed at execution time by way of "new RegExp(...)".
This commit is contained in:
committed by
Linus Groh
parent
1400e3cf58
commit
f1dd770a8a
@@ -2020,7 +2020,9 @@ void RegExpLiteral::dump(int indent) const
|
||||
Value RegExpLiteral::execute(Interpreter& interpreter, GlobalObject& global_object) const
|
||||
{
|
||||
InterpreterNodeScope node_scope { interpreter, *this };
|
||||
return regexp_create(global_object, js_string(interpreter.heap(), pattern()), js_string(interpreter.heap(), flags()));
|
||||
|
||||
Regex<ECMA262> regex(parsed_regex(), parsed_pattern(), parsed_flags());
|
||||
return RegExpObject::create(global_object, move(regex), pattern(), flags());
|
||||
}
|
||||
|
||||
void ArrayExpression::dump(int indent) const
|
||||
|
||||
Reference in New Issue
Block a user