Skip to content

Commit

Permalink
Handle debugger statements as if-statement branches (#3769)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Sep 8, 2020
1 parent fe0bdd6 commit 6697ee4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,14 @@
# rollup changelog

## 2.26.11
*2020-09-08*

### Bug Fixes
* Do not fail for unknown nodes as if statement branches (#3769)

### Pull Requests
* [#3769](https://github.com/rollup/rollup/pull/3769): Handle debugger statements as if-statement branches (@lukastaegert)

## 2.26.10
*2020-09-04*

Expand Down
14 changes: 4 additions & 10 deletions src/ast/nodes/IfStatement.ts
Expand Up @@ -70,18 +70,12 @@ export default class IfStatement extends StatementBase implements DeoptimizableE

parseNode(esTreeNode: GenericEsTreeNode) {
this.consequentScope = new TrackingScope(this.scope);
this.consequent = new this.context.nodeConstructors[esTreeNode.consequent.type](
esTreeNode.consequent,
this,
this.consequentScope
);
this.consequent = new (this.context.nodeConstructors[esTreeNode.consequent.type] ||
this.context.nodeConstructors.UnknownNode)(esTreeNode.consequent, this, this.consequentScope);
if (esTreeNode.alternate) {
this.alternateScope = new TrackingScope(this.scope);
this.alternate = new this.context.nodeConstructors[esTreeNode.alternate.type](
esTreeNode.alternate,
this,
this.alternateScope
);
this.alternate = new (this.context.nodeConstructors[esTreeNode.alternate.type] ||
this.context.nodeConstructors.UnknownNode)(esTreeNode.alternate, this, this.alternateScope);
}
super.parseNode(esTreeNode);
}
Expand Down
3 changes: 3 additions & 0 deletions test/function/samples/unknown-statement/_config.js
@@ -0,0 +1,3 @@
module.exports = {
description: 'handles unknown statements'
};
4 changes: 4 additions & 0 deletions test/function/samples/unknown-statement/main.js
@@ -0,0 +1,4 @@
debugger;

if (true) debugger;
else debugger;

0 comments on commit 6697ee4

Please sign in to comment.