Index: src/runtime/runtime-object.cc |
diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc |
index 5945488831e9a705881845f988db47d91e5f9753..6287c98f3eb00e43a783a9df1edfe6d59301c246 100644 |
--- a/src/runtime/runtime-object.cc |
+++ b/src/runtime/runtime-object.cc |
@@ -753,28 +753,28 @@ RUNTIME_FUNCTION(Runtime_HasOwnProperty) { |
} |
+// ES6 section 12.9.3, operator in. |
RUNTIME_FUNCTION(Runtime_HasProperty) { |
HandleScope scope(isolate); |
- DCHECK(args.length() == 2); |
- CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
- CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
+ DCHECK_EQ(2, args.length()); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, key, 0); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, object, 1); |
+ |
+ // Check that {object} is actually a receiver. |
+ if (!object->IsJSReceiver()) { |
+ THROW_NEW_ERROR_RETURN_FAILURE( |
+ isolate, |
+ NewTypeError(MessageTemplate::kInvalidInOperatorUse, key, object)); |
+ } |
+ Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(object); |
+ // Convert the {key} to a name. |
Handle<Name> name; |
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, |
Object::ToName(isolate, key)); |
- Maybe<bool> maybe = JSReceiver::HasProperty(receiver, name); |
- if (!maybe.IsJust()) return isolate->heap()->exception(); |
- return isolate->heap()->ToBoolean(maybe.FromJust()); |
-} |
- |
-RUNTIME_FUNCTION(Runtime_HasElement) { |
- HandleScope scope(isolate); |
- DCHECK(args.length() == 2); |
- CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
- CONVERT_SMI_ARG_CHECKED(index, 1); |
- |
- Maybe<bool> maybe = JSReceiver::HasElement(receiver, index); |
+ // Lookup the {name} on {receiver}. |
+ Maybe<bool> maybe = JSReceiver::HasProperty(receiver, name); |
if (!maybe.IsJust()) return isolate->heap()->exception(); |
return isolate->heap()->ToBoolean(maybe.FromJust()); |
} |