Skip to content

Commit 3b7112c

Browse files
committed
This arugment must be pseudo-array in {Map/Set}Iterator.prototype.next routine
This patch fixes #2950. Co-authored-by: Gabor Loki loki@inf.u-szeged.hu JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
1 parent 04d5d56 commit 3b7112c

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

jerry-core/ecma/operations/ecma-container-object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ ecma_op_container_iterator_next (ecma_value_t this_val, /**< this argument */
698698
ecma_object_t *obj_p = ecma_get_object_from_value (this_val);
699699
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
700700

701-
if (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_PSEUDO_ARRAY
701+
if (ecma_get_object_type (obj_p) != ECMA_OBJECT_TYPE_PSEUDO_ARRAY
702702
&& ext_obj_p->u.pseudo_array.type != iterator_type)
703703
{
704704
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an iterator."));
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific lang
13+
14+
var str = new Map();
15+
var iterator = str[ Symbol.iterator ]();
16+
17+
try {
18+
iterator.next.call({ })
19+
assert(false);
20+
} catch (e) {
21+
assert(e instanceof TypeError);
22+
}

0 commit comments

Comments
 (0)