Skip to content

Commit 2a37821

Browse files
author
Robert Fancsik
authored
Fix fast array objects cannot hold private properties (#4952)
This patch fixes #4934. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
1 parent 8fa7819 commit 2a37821

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

jerry-core/vm/opcodes.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,11 @@ opfunc_find_private_key (ecma_object_t *class_object_p, /**< class environment *
12351235
ecma_string_t *search_key_p, /**< key */
12361236
ecma_string_t **out_private_key_p) /**< [out] private key */
12371237
{
1238+
if (ecma_op_object_is_fast_array (obj_p))
1239+
{
1240+
return NULL;
1241+
}
1242+
12381243
ecma_string_t *internal_string_p = ecma_get_internal_string (LIT_INTERNAL_MAGIC_STRING_CLASS_PRIVATE_ELEMENTS);
12391244
ecma_property_t *prop_p = ecma_find_named_property (class_object_p, internal_string_p);
12401245

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 language governing permissions and
13+
// limitations under the License.
14+
15+
function expectTypeError(cb) {
16+
try {
17+
cb();
18+
assert(false);
19+
} catch (e) {
20+
assert(e instanceof TypeError);
21+
}
22+
}
23+
24+
class JSEtest {
25+
static set #m(v) {
26+
this._v = v;
27+
}
28+
29+
static b() {
30+
new Proxy([1], {}).#m = "Test262";
31+
}
32+
33+
static c() {
34+
[1].#m = "Test262";
35+
}
36+
}
37+
38+
expectTypeError(_ => JSEtest.b());
39+
expectTypeError(_ => JSEtest.c());

0 commit comments

Comments
 (0)