From 9abcb7ece196962889b673b678ccb11cbc03a1cc Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Mon, 10 Jun 2019 07:29:53 +0200 Subject: [PATCH] Properly include try statements for each pass when deoptimization is deactivated (#2914) --- src/ast/nodes/TryStatement.ts | 2 +- .../deactivate-via-option/_expected.js | 9 +++++++++ .../deactivate-via-option/main.js | 7 +++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/ast/nodes/TryStatement.ts b/src/ast/nodes/TryStatement.ts index c31a839c74d..3b0df7e1207 100644 --- a/src/ast/nodes/TryStatement.ts +++ b/src/ast/nodes/TryStatement.ts @@ -21,7 +21,7 @@ export default class TryStatement extends StatementBase { } include(includeChildrenRecursively: IncludeChildren) { - if (!this.directlyIncluded) { + if (!this.directlyIncluded || !this.context.tryCatchDeoptimization) { this.included = true; this.directlyIncluded = true; this.block.include( diff --git a/test/form/samples/try-statement-deoptimization/deactivate-via-option/_expected.js b/test/form/samples/try-statement-deoptimization/deactivate-via-option/_expected.js index b6a9ec668aa..d480f2fc810 100644 --- a/test/form/samples/try-statement-deoptimization/deactivate-via-option/_expected.js +++ b/test/form/samples/try-statement-deoptimization/deactivate-via-option/_expected.js @@ -1,8 +1,17 @@ +function mutate(foo) { + foo.bar = 1; +} + +const mutated = {}; + function test(callback) { try { callback(); + mutate(mutated); } catch {} } test(() => { }); + +export { mutated }; diff --git a/test/form/samples/try-statement-deoptimization/deactivate-via-option/main.js b/test/form/samples/try-statement-deoptimization/deactivate-via-option/main.js index e823e4a0503..e413c193e81 100644 --- a/test/form/samples/try-statement-deoptimization/deactivate-via-option/main.js +++ b/test/form/samples/try-statement-deoptimization/deactivate-via-option/main.js @@ -2,11 +2,18 @@ function callGlobal() { Object.create(null); } +function mutate(foo) { + foo.bar = 1; +} + +export const mutated = {}; + function test(callback) { try { Object.create(null); callback(); callGlobal(); + mutate(mutated); } catch {} }