Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle debugger statements as if-statement branches #3769

Merged
merged 1 commit into from
Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
description: 'handles unknown statements'
};
4 changes: 4 additions & 0 deletions test/function/samples/unknown-statement/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
debugger;

if (true) debugger;
else debugger;