Skip to content

Commit efdf91a

Browse files
yichoiejjeong
authored andcommitted
Regexp.prototype.exec should not generate return array with [[Put]]
Releated issue: #1078 JerryScript-DCO-1.0-Signed-off-by: Youngil Choi [email protected]
1 parent 314e74f commit efdf91a

File tree

3 files changed

+27
-19
lines changed

3 files changed

+27
-19
lines changed

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,15 +1434,13 @@ ecma_regexp_exec_helper (ecma_value_t regexp_value, /**< RegExp object */
14341434
capture_value = ecma_make_string_value (capture_str_p);
14351435
}
14361436

1437-
ECMA_TRY_CATCH (put_value,
1438-
ecma_op_object_put (result_array_obj_p,
1439-
index_str_p,
1440-
capture_value,
1441-
true),
1442-
ret_value);
1443-
ECMA_FINALIZE (put_value);
1444-
1445-
ecma_free_value (capture_value);
1437+
ecma_property_t *prop_p;
1438+
prop_p = ecma_create_named_data_property (result_array_obj_p,
1439+
index_str_p,
1440+
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
1441+
ecma_set_named_data_property_value (prop_p, capture_value);
1442+
1443+
JERRY_ASSERT (!ecma_is_value_object (capture_value));
14461444
ecma_deref_ecma_string (index_str_p);
14471445
}
14481446

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2016 Samsung Electronics Co., Ltd.
2+
// Copyright 2016 University of Szeged.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
Array.prototype.splice(Function.prototype, 1, this);
17+
Object.freeze(Array.prototype);
18+
var res = (new String("Hello")).split(new RegExp());
19+
assert(res.length == 5);

tests/jerry/regression-test-issue-787.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,4 @@
1515

1616
Array.prototype.push(Math.sin);
1717
Object.freeze(Array.prototype);
18-
19-
try
20-
{
21-
String.prototype.match(String.prototype);
22-
assert (false);
23-
}
24-
catch (e)
25-
{
26-
assert (e instanceof TypeError);
27-
}
18+
String.prototype.match(String.prototype);

0 commit comments

Comments
 (0)