Skip to content

Commit

Permalink
Fixed bug when parsing a semicolon on a new line after break and cont…
Browse files Browse the repository at this point in the history
…inue statements
  • Loading branch information
mck89 committed Jun 21, 2020
1 parent 7444820 commit e11664e
Show file tree
Hide file tree
Showing 7 changed files with 654 additions and 13 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.10.3-dev"
"dev-master": "1.10.4-dev"
}
}
}
1 change: 1 addition & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
#### 1.10.4
* Implemented parsing of coalescing operator
* Implemented parsing of optional chaining
* Fixed bug when parsing a semicolon on a new line after break and continue statements

#### 1.10.3
* Implemented parsing of `import.meta` syntax
Expand Down
25 changes: 13 additions & 12 deletions lib/Peast/Syntax/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -646,14 +646,15 @@ protected function parseContinueStatement()

$node = $this->createNode("ContinueStatement", $token);

if ($this->scanner->noLineTerminators()) {
if ($label = $this->parseIdentifier(static::$labelledIdentifier)) {
$node->setLabel($label);
}
if ($this->scanner->noLineTerminators() &&
($label = $this->parseIdentifier(static::$labelledIdentifier))
) {
$node->setLabel($label);
$this->assertEndOfStatement();
} else {
$this->scanner->consume(";");
}

$this->assertEndOfStatement();

return $this->completeNode($node);
}
return null;
Expand All @@ -670,14 +671,14 @@ protected function parseBreakStatement()

$node = $this->createNode("BreakStatement", $token);

if ($this->scanner->noLineTerminators()) {
if ($label = $this->parseIdentifier(static::$labelledIdentifier)) {
$node->setLabel($label);
}
if ($this->scanner->noLineTerminators() &&
($label = $this->parseIdentifier(static::$labelledIdentifier))) {
$node->setLabel($label);
$this->assertEndOfStatement();
} else {
$this->scanner->consume(";");
}

$this->assertEndOfStatement();

return $this->completeNode($node);
}
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
for (; ; ) {
if (true) {
break;
} else {
}
if (true) {
continue;
} else {
}
}
/**************************************************/
for(;;){if(true)break;else{}if(true)continue;else{}}
/**************************************************/
for ( ; ; )
{
if ( true )
{
break;
} else
{
}
if ( true )
{
continue;
} else
{
}
}
Loading

0 comments on commit e11664e

Please sign in to comment.