浏览代码

LibJS: Set NativeError constructors' prototype to Error constructor

The FunctionPrototype is correct for ErrorConstructor itself:

    20.5.2 Properties of the Error Constructor

    The Error constructor:
    - has a [[Prototype]] internal slot whose value is
      %Function.prototype%.

However, not for all the other "NativeError" constructors:

    20.5.6.2 Properties of the NativeError Constructors

    Each NativeError constructor:
    - has a [[Prototype]] internal slot whose value is %Error%.
Linus Groh 4 年之前
父节点
当前提交
0e38c9b2f7
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp

+ 1 - 1
Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp

@@ -42,7 +42,7 @@ Value ErrorConstructor::construct(Function&)
 
 
 #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
 #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
     ConstructorName::ConstructorName(GlobalObject& global_object)                        \
     ConstructorName::ConstructorName(GlobalObject& global_object)                        \
-        : NativeFunction(*global_object.function_prototype())                            \
+        : NativeFunction(*static_cast<Object*>(global_object.error_constructor()))       \
     {                                                                                    \
     {                                                                                    \
     }                                                                                    \
     }                                                                                    \
                                                                                          \
                                                                                          \