diff --git a/jerry-core/ecma/builtin-objects/ecma-builtins.inc.h b/jerry-core/ecma/builtin-objects/ecma-builtins.inc.h index f0d606bb4..b2597aa16 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtins.inc.h +++ b/jerry-core/ecma/builtin-objects/ecma-builtins.inc.h @@ -225,6 +225,12 @@ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_REGEXP, regexp) #endif /* ENABLED (JERRY_BUILTIN_REGEXP) */ +#if ENABLED (JERRY_ES2015) +#define ECMA_BUILTIN_NATIVE_ERROR_PROTOTYPE_ID ECMA_BUILTIN_ID_ERROR +#else /* !ENABLED (JERRY_ES2015) */ +#define ECMA_BUILTIN_NATIVE_ERROR_PROTOTYPE_ID ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE +#endif /* ENABLED (JERRY_ES2015 */ + /* The Error object (15.11.1) */ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_ERROR, ECMA_OBJECT_TYPE_FUNCTION, @@ -250,7 +256,7 @@ BUILTIN (ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE, /* The EvalError object (15.11.6.1) */ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_EVAL_ERROR, ECMA_OBJECT_TYPE_FUNCTION, - ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE, + ECMA_BUILTIN_NATIVE_ERROR_PROTOTYPE_ID, true, eval_error) @@ -264,7 +270,7 @@ BUILTIN (ECMA_BUILTIN_ID_RANGE_ERROR_PROTOTYPE, /* The RangeError object (15.11.6.2) */ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_RANGE_ERROR, ECMA_OBJECT_TYPE_FUNCTION, - ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE, + ECMA_BUILTIN_NATIVE_ERROR_PROTOTYPE_ID, true, range_error) @@ -278,7 +284,7 @@ BUILTIN (ECMA_BUILTIN_ID_REFERENCE_ERROR_PROTOTYPE, /* The ReferenceError object (15.11.6.3) */ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_REFERENCE_ERROR, ECMA_OBJECT_TYPE_FUNCTION, - ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE, + ECMA_BUILTIN_NATIVE_ERROR_PROTOTYPE_ID, true, reference_error) @@ -292,7 +298,7 @@ BUILTIN (ECMA_BUILTIN_ID_SYNTAX_ERROR_PROTOTYPE, /* The SyntaxError object (15.11.6.4) */ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_SYNTAX_ERROR, ECMA_OBJECT_TYPE_FUNCTION, - ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE, + ECMA_BUILTIN_NATIVE_ERROR_PROTOTYPE_ID, true, syntax_error) @@ -306,7 +312,7 @@ BUILTIN (ECMA_BUILTIN_ID_TYPE_ERROR_PROTOTYPE, /* The TypeError object (15.11.6.5) */ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_TYPE_ERROR, ECMA_OBJECT_TYPE_FUNCTION, - ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE, + ECMA_BUILTIN_NATIVE_ERROR_PROTOTYPE_ID, true, type_error) @@ -320,7 +326,7 @@ BUILTIN (ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE, /* The URIError object (15.11.6.6) */ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_URI_ERROR, ECMA_OBJECT_TYPE_FUNCTION, - ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE, + ECMA_BUILTIN_NATIVE_ERROR_PROTOTYPE_ID, true, uri_error) #endif /* ENABLED (JERRY_BUILTIN_ERRORS) */ diff --git a/tests/jerry/es2015/error.js b/tests/jerry/es2015/error.js new file mode 100644 index 000000000..4f1daa538 --- /dev/null +++ b/tests/jerry/es2015/error.js @@ -0,0 +1,21 @@ +// Copyright JS Foundation and other contributors, http://js.foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* Prototype of NativeErrors should be Error */ +assert(Object.getPrototypeOf(EvalError) === Error); +assert(Object.getPrototypeOf(RangeError) === Error); +assert(Object.getPrototypeOf(ReferenceError) === Error); +assert(Object.getPrototypeOf(SyntaxError) === Error); +assert(Object.getPrototypeOf(TypeError) === Error); +assert(Object.getPrototypeOf(URIError) === Error);