From 9f9015a37d5f772753c395837ac79c1339396ded Mon Sep 17 00:00:00 2001 From: ctw Date: Wed, 2 Mar 2022 14:37:20 +0800 Subject: [PATCH] Fix incorrect scope location of catch block Signed-off-by: ctw Change-Id: If1d40d8bbe7c10e384862ebc3fbd6e9cad5566ab --- ts2panda/src/statement/tryStatement.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ts2panda/src/statement/tryStatement.ts b/ts2panda/src/statement/tryStatement.ts index d720e5420d..c5a8177115 100644 --- a/ts2panda/src/statement/tryStatement.ts +++ b/ts2panda/src/statement/tryStatement.ts @@ -206,8 +206,10 @@ export class TryBuilder extends TryBuilderBase { this.compiler.pushScope(catchClause); compileCatchClauseVariableDeclaration(this.compiler, catchClause.variableDeclaration); let catchBlock = catchClause.block; + this.compiler.pushScope(catchBlock); catchBlock.statements.forEach((stmt) => this.compiler.compileStatement(stmt)); this.compiler.popScope(); + this.compiler.popScope(); } else { // finallyBlock rethrow exception when it catch the exception let exceptionVreg = this.pandaGen.getTemp(); -- Gitee