From 6efe14d1bdfba40e3fae662626936ea6643ed226 Mon Sep 17 00:00:00 2001 From: Robert Fancsik Date: Mon, 10 Jan 2022 16:37:35 +0100 Subject: [PATCH] Add missing object types for ecma_object_get_class_name (#4954) This patch fixes #4937 and fixes #4938. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu --- jerry-core/ecma/operations/ecma-objects.c | 2 ++ .../es.next/regression-test-issue-4937-4938.js | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/jerry/es.next/regression-test-issue-4937-4938.js diff --git a/jerry-core/ecma/operations/ecma-objects.c b/jerry-core/ecma/operations/ecma-objects.c index b6462ddc1e..6036fff984 100644 --- a/jerry-core/ecma/operations/ecma-objects.c +++ b/jerry-core/ecma/operations/ecma-objects.c @@ -2762,6 +2762,7 @@ ecma_object_check_class_name_is_object (ecma_object_t *obj_p) /**< object */ || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_FLOAT64ARRAY_PROTOTYPE) #endif /* JERRY_NUMBER_TYPE_FLOAT64 */ #if JERRY_BUILTIN_BIGINT + || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_BIGINT_PROTOTYPE) || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_BIGINT64ARRAY_PROTOTYPE) || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_BIGUINT64ARRAY_PROTOTYPE) #endif /* JERRY_BUILTIN_BIGINT */ @@ -2936,6 +2937,7 @@ ecma_object_get_class_name (ecma_object_t *obj_p) /**< object */ case ECMA_OBJECT_TYPE_NATIVE_FUNCTION: case ECMA_OBJECT_TYPE_BOUND_FUNCTION: case ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION: + case ECMA_OBJECT_TYPE_CONSTRUCTOR_FUNCTION: { return LIT_MAGIC_STRING_FUNCTION_UL; } diff --git a/tests/jerry/es.next/regression-test-issue-4937-4938.js b/tests/jerry/es.next/regression-test-issue-4937-4938.js new file mode 100644 index 0000000000..5fb006997b --- /dev/null +++ b/tests/jerry/es.next/regression-test-issue-4937-4938.js @@ -0,0 +1,16 @@ +// 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. + +assert(Object.prototype.toString.call(class {}) === "[object Function]"); +assert(Object.prototype.toString.call(BigInt.prototype) === "[object BigInt]");