Skip to content

Commit d37ff33

Browse files
author
Robert Fancsik
authored
Fix class constructor as accessor check (#4880)
This patch fixes #4874. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
1 parent ee59c22 commit d37ff33

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

jerry-core/parser/js/js-parser-expr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ parser_parse_class_body (parser_context_t *context_p, /**< context */
726726
}
727727
else if (parser_is_constructor_literal (context_p))
728728
{
729-
JERRY_ASSERT (!is_static);
729+
JERRY_ASSERT (!is_static || is_private);
730730
parser_raise_error (context_p, PARSER_ERR_CLASS_CONSTRUCTOR_AS_ACCESSOR);
731731
}
732732

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
// Make sure that TypedArray filter correctly copies the data (avoid overflow).
16+
// Test creates a smaller region for "output" TypedArray.
17+
// Last number is intentionally a "big" float.
18+
19+
for (let key of ['get', 'set']) {
20+
try {
21+
eval(`class { static ${key} #constructor() {} }`);
22+
} catch (e) {
23+
assert(e instanceof SyntaxError);
24+
}
25+
}

0 commit comments

Comments
 (0)