瀏覽代碼

LibJS: Don't suppress GlobalObject variable lookup exceptions

In HackStudio's Debugger a custom GlobalObject is used to reflect
debugger variables into the JS scope by overriding GlobalObject's
get method. However, when throwing a custom error during that lookup
it was replaced with the generic "not found" js exception. This patch
makes it instead pass along the custom error.
FalseHonesty 4 年之前
父節點
當前提交
bee16bb83a
共有 2 個文件被更改,包括 4 次插入1 次删除
  1. 2 1
      Userland/Libraries/LibJS/AST.cpp
  2. 2 0
      Userland/Libraries/LibJS/Runtime/VM.cpp

+ 2 - 1
Userland/Libraries/LibJS/AST.cpp

@@ -1251,7 +1251,8 @@ Value Identifier::execute(Interpreter& interpreter, GlobalObject& global_object)
 
     auto value = interpreter.vm().get_variable(string(), global_object);
     if (value.is_empty()) {
-        interpreter.vm().throw_exception<ReferenceError>(global_object, ErrorType::UnknownIdentifier, string());
+        if (!interpreter.exception())
+            interpreter.vm().throw_exception<ReferenceError>(global_object, ErrorType::UnknownIdentifier, string());
         return {};
     }
     return value;

+ 2 - 0
Userland/Libraries/LibJS/Runtime/VM.cpp

@@ -173,6 +173,8 @@ Value VM::get_variable(const FlyString& name, GlobalObject& global_object)
 
         for (auto* scope = current_scope(); scope; scope = scope->parent()) {
             auto possible_match = scope->get_from_scope(name);
+            if (exception())
+                return {};
             if (possible_match.has_value())
                 return possible_match.value().value;
         }