File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -119,16 +119,18 @@ parser_check_invalid_assign (parser_context_t *context_p) /**< context */
119119 */
120120static void
121121parser_check_invalid_new_target (parser_context_t * context_p , /**< parser context */
122- cbc_opcode_t opcode ) /**< current opcode under parsing */
122+ cbc_opcode_t opcode ) /**< current opcode under parsing */
123123{
124- JERRY_ASSERT ((opcode >= CBC_PRE_INCR && opcode <= CBC_POST_DECR )
125- || (opcode == CBC_ASSIGN
126- && (context_p -> token .type == LEXER_ASSIGN
127- || LEXER_IS_BINARY_LVALUE_TOKEN (context_p -> token .type ))));
128-
129124 /* new.target is an invalid left-hand side target */
130125 if (context_p -> last_cbc_opcode == PARSER_TO_EXT_OPCODE (CBC_EXT_PUSH_NEW_TARGET ))
131126 {
127+ /* Make sure that the call side is a post/pre increment or an assignment expression.
128+ * There should be no other ways the "new.target" expression should be here. */
129+ JERRY_ASSERT ((opcode >= CBC_PRE_INCR && opcode <= CBC_POST_DECR )
130+ || (opcode == CBC_ASSIGN
131+ && (context_p -> token .type == LEXER_ASSIGN
132+ || LEXER_IS_BINARY_LVALUE_TOKEN (context_p -> token .type ))));
133+
132134 parser_raise_error (context_p , PARSER_ERR_NEW_TARGET_NOT_ALLOWED );
133135 }
134136} /* parser_check_invalid_new_target */
Original file line number Diff line number Diff line change 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 method ( ) {
16+ [ "" ] = $
17+ }
18+
19+ try {
20+ eval ( "function mm () { [new.target] = 3; }" ) ;
21+ assert ( false ) ;
22+ } catch ( ex ) {
23+ assert ( ex instanceof SyntaxError ) ;
24+ }
You can’t perform that action at this time.
0 commit comments