Skip to content

Commit a7c6546

Browse files
zherczegrerobika
authored andcommitted
There is no need to update the scanner info chain after a for/while statement. (#3138)
Fixes #3131. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
1 parent 1acbf83 commit a7c6546

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,8 +842,9 @@ parser_parse_while_statement_end (parser_context_t *context_p) /**< context */
842842
parser_emit_cbc_backward_branch (context_p, (uint16_t) opcode, while_statement.start_offset);
843843
parser_set_breaks_to_current_position (context_p, loop.branch_list_p);
844844

845+
/* Calling scanner_seek is unnecessary because all
846+
* info blocks inside the while statement should be processed. */
845847
scanner_set_location (context_p, &location);
846-
scanner_seek (context_p);
847848
context_p->token = current_token;
848849
} /* parser_parse_while_statement_end */
849850

@@ -1186,8 +1187,9 @@ parser_parse_for_statement_end (parser_context_t *context_p) /**< context */
11861187
parser_emit_cbc_backward_branch (context_p, (uint16_t) opcode, for_statement.start_offset);
11871188
parser_set_breaks_to_current_position (context_p, loop.branch_list_p);
11881189

1190+
/* Calling scanner_seek is unnecessary because all
1191+
* info blocks inside the for statement should be processed. */
11891192
scanner_set_location (context_p, &location);
1190-
scanner_seek (context_p);
11911193
context_p->token = current_token;
11921194
} /* parser_parse_for_statement_end */
11931195

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
switch ( $) { case $: for ( ; ; ) ; case $ :}

tests/jerry/switch-case.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,6 @@ switch ("var") {
103103
}
104104

105105
assert (flow === '123a4');
106+
107+
switch (0) { case 0: for (;false;); case 1: }
108+
switch (0) { case 0: while (false); case 1: }

0 commit comments

Comments
 (0)