[runtime] Adding more detailed error message for Object::GetMethod.
BUG= Review URL: https://codereview.chromium.org/1484393002 Cr-Commit-Position: refs/heads/master@{#32506}
This commit is contained in:
parent
4013a8df54
commit
9cffd0d2ce
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user