Skip to content

Commit

Permalink
Properly include try-catch-statements even if they have already been (#…
Browse files Browse the repository at this point in the history
…2898)

included via another means
  • Loading branch information
lukastaegert committed Jun 5, 2019
1 parent 6f9c3b5 commit 71f2fa8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ast/nodes/TryStatement.ts
Expand Up @@ -10,6 +10,8 @@ export default class TryStatement extends StatementBase {
handler!: CatchClause | null;
type!: NodeType.tTryStatement;

private directlyIncluded = false;

hasEffects(options: ExecutionPathOptions): boolean {
return (
this.block.body.length > 0 ||
Expand All @@ -19,8 +21,9 @@ export default class TryStatement extends StatementBase {
}

include(includeChildrenRecursively: IncludeChildren) {
if (!this.included) {
if (!this.directlyIncluded) {
this.included = true;
this.directlyIncluded = true;
this.block.include(
this.context.tryCatchDeoptimization ? INCLUDE_VARIABLES : includeChildrenRecursively
);
Expand Down
@@ -0,0 +1,3 @@
module.exports = {
description: 'works when the try-statement is included via an outside variable'
};
@@ -0,0 +1,6 @@
console.log(myVar);

try {
var myVar = 3;
console.log(myVar);
} catch {}
@@ -0,0 +1,6 @@
console.log(myVar);

try {
var myVar = 3;
console.log(myVar);
} catch {}

0 comments on commit 71f2fa8

Please sign in to comment.