From 167495b87bf9dbcc0cf9f55883e4e860934a5a74 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sat, 8 Jul 2023 20:29:13 +0200 Subject: [PATCH] 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. --- Userland/Libraries/LibJS/Bytecode/Generator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Bytecode/Generator.cpp b/Userland/Libraries/LibJS/Bytecode/Generator.cpp index 88398297d0..b40f24e286 100644 --- a/Userland/Libraries/LibJS/Bytecode/Generator.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Generator.cpp @@ -298,7 +298,10 @@ CodeGenerationErrorOr Generator::emit_delete_reference(JS::ASTNode const& { if (is(node)) { auto& identifier = static_cast(node); - emit(intern_identifier(identifier.string())); + if (identifier.is_local()) + emit(Value(false)); + else + emit(intern_identifier(identifier.string())); return {}; }