Explorar o código

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 %!s(int64=4) %!d(string=hai) anos
pai
achega
0e38c9b2f7
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  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) \
     ConstructorName::ConstructorName(GlobalObject& global_object)                        \
-        : NativeFunction(*global_object.function_prototype())                            \
+        : NativeFunction(*static_cast<Object*>(global_object.error_constructor()))       \
     {                                                                                    \
     }                                                                                    \
                                                                                          \