Skip to content

Commit

Permalink
Do not call generateStatementByteCode for RegExpLiteral node in for s…
Browse files Browse the repository at this point in the history
…tatement

Fixes Samsung#35

Signed-off-by: Robert Sipka <[email protected]>
  • Loading branch information
robertsipka committed Jan 23, 2019
1 parent c21afcb commit 6cfa158
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/parser/ast/ForStatementNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class ForStatementNode : public StatementNode {

newContext.getRegister(); // ExeuctionResult of m_body should not be overwritten by m_test

if (m_init) {

if (m_init && m_init->type() != ASTNodeType::RegExpLiteral) {
m_init->generateStatementByteCode(codeBlock, &newContext);
}

Expand Down
18 changes: 18 additions & 0 deletions test/regression-tests/issue-35.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* Copyright 2019-present Samsung Electronics Co., Ltd. and other contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

for ( // ; ; ) {
break;
}

0 comments on commit 6cfa158

Please sign in to comment.