From c7a1a3d680e9971661bcb4045032f98e644858a1 Mon Sep 17 00:00:00 2001 From: ctw Date: Tue, 1 Mar 2022 20:34:39 +0800 Subject: [PATCH] fix incorrect scope location of catch block Signed-off-by: ctw Change-Id: I1a599fb83b18b15d50cd327fc9d5ce92aa7107e7 --- 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 23399828d6..2ae2fa97d5 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