Commit 9cffd0d2 authored by cbruni's avatar cbruni Committed by Commit bot

[runtime] Adding more detailed error message for Object::GetMethod.

BUG=

Review URL: https://codereview.chromium.org/1484393002

Cr-Commit-Position: refs/heads/master@{#32506}
parent 4013a8df
......@@ -134,7 +134,7 @@ function SetConstructor(iterable) {
if (!IS_NULL_OR_UNDEFINED(iterable)) {
var adder = this.add;
if (!IS_CALLABLE(adder)) {
throw MakeTypeError(kPropertyNotFunction, 'add', this);
throw MakeTypeError(kPropertyNotFunction, adder, 'add', this);
}
for (var value of iterable) {
......@@ -290,7 +290,7 @@ function MapConstructor(iterable) {
if (!IS_NULL_OR_UNDEFINED(iterable)) {
var adder = this.set;
if (!IS_CALLABLE(adder)) {
throw MakeTypeError(kPropertyNotFunction, 'set', this);
throw MakeTypeError(kPropertyNotFunction, adder, 'set', this);
}
for (var nextItem of iterable) {
......
......@@ -38,7 +38,7 @@ function WeakMapConstructor(iterable) {
if (!IS_NULL_OR_UNDEFINED(iterable)) {
var adder = this.set;
if (!IS_CALLABLE(adder)) {
throw MakeTypeError(kPropertyNotFunction, 'set', this);
throw MakeTypeError(kPropertyNotFunction, adder, 'set', this);
}
for (var nextItem of iterable) {
if (!IS_SPEC_OBJECT(nextItem)) {
......@@ -127,7 +127,7 @@ function WeakSetConstructor(iterable) {
if (!IS_NULL_OR_UNDEFINED(iterable)) {
var adder = this.add;
if (!IS_CALLABLE(adder)) {
throw MakeTypeError(kPropertyNotFunction, 'add', this);
throw MakeTypeError(kPropertyNotFunction, adder, 'add', this);
}
for (var value of iterable) {
%_Call(adder, this, value);
......
......@@ -178,7 +178,8 @@ class CallSite {
"Function object that's not a constructor was created with new") \
T(PromiseCyclic, "Chaining cycle detected for promise %") \
T(PropertyDescObject, "Property description must be an object: %") \
T(PropertyNotFunction, "Property '%' of object % is not a function") \
T(PropertyNotFunction, \
"'%' returned for property '%' of object '%' is not a function") \
T(ProtoObjectOrNull, "Object prototype may only be an Object or null: %") \
T(PrototypeParentNotAnObject, \
"Class extends value does not have valid prototype property %") \
......
......@@ -636,9 +636,8 @@ MaybeHandle<Object> Object::GetMethod(Handle<JSReceiver> receiver,
return isolate->factory()->undefined_value();
}
if (!func->IsCallable()) {
// TODO(bmeurer): Better error message here?
THROW_NEW_ERROR(isolate,
NewTypeError(MessageTemplate::kCalledNonCallable, func),
THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kPropertyNotFunction,
func, name, receiver),
Object);
}
return func;
......
......@@ -1477,6 +1477,6 @@ TEST(FormatMessage) {
MessageTemplate::FormatMessage(MessageTemplate::kPropertyNotFunction,
arg0, arg1, arg2).ToHandleChecked();
Handle<String> expected = isolate->factory()->NewStringFromAsciiChecked(
"Property 'arg0' of object arg1 is not a function");
"'arg0' returned for property 'arg1' of object 'arg2' is not a function");
CHECK(String::Equals(result, expected));
}
......@@ -256,7 +256,7 @@ test(function() {
test(function() {
Set.prototype.add = 0;
new Set(1);
}, "Property 'add' of object #<Set> is not a function", TypeError);
}, "'0' returned for property 'add' of object '#<Set>' is not a function", TypeError);
// kProtoObjectOrNull
test(function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment