mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 21:59:07 +00:00
LibJS/Bytecode: Always return false on attempt to delete local variable
Since it is not possible for delete operator to return true when it is applied to local variable, DeleteVariable can safely always return false for locals. This also fixes operators/delete-local-variable.js in test-js.
This commit is contained in:
parent
0c5c75e8a4
commit
167495b87b
Notes:
sideshowbarker
2024-07-17 03:16:02 +09:00
Author: https://github.com/kalenikaliaksandr
Commit: 167495b87b
Pull-request: https://github.com/SerenityOS/serenity/pull/19889
Reviewed-by: https://github.com/awesomekling
1 changed files with 4 additions and 1 deletions
|
@ -298,7 +298,10 @@ CodeGenerationErrorOr<void> Generator::emit_delete_reference(JS::ASTNode const&
|
|||
{
|
||||
if (is<Identifier>(node)) {
|
||||
auto& identifier = static_cast<Identifier const&>(node);
|
||||
emit<Bytecode::Op::DeleteVariable>(intern_identifier(identifier.string()));
|
||||
if (identifier.is_local())
|
||||
emit<Bytecode::Op::LoadImmediate>(Value(false));
|
||||
else
|
||||
emit<Bytecode::Op::DeleteVariable>(intern_identifier(identifier.string()));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue