From 1b6b3b4d40e85c2bdbc6a76107fbfa888e600144 Mon Sep 17 00:00:00 2001 From: hufeng Date: Thu, 28 Jul 2022 21:24:14 +0800 Subject: [PATCH] Close Iteratr when array bindingpattern is empty Signed-off-by: hufeng Change-Id: I6bc6412801f2b07d6be5fd3cdf14413d67249e9c --- ts2panda/src/compilerUtils.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ts2panda/src/compilerUtils.ts b/ts2panda/src/compilerUtils.ts index 42082fb7c2..01734351a4 100644 --- a/ts2panda/src/compilerUtils.ts +++ b/ts2panda/src/compilerUtils.ts @@ -66,6 +66,12 @@ function compileArrayDestructuring(arr: ts.ArrayBindingOrAssignmentPattern, pand let iterator = new Iterator({iterator: iter, nextMethod: nextMethod}, iterDone, iterValue, pandaGen, arr); iterator.getIterator(); + if (arr.elements.length === 0) { + iterator.close(); + pandaGen.freeTemps(iter, nextMethod, iterDone, iterValue, nextResult, exception); + return; + } + // prepare try-catch for iterate over all the elements let tryBeginLabel = new Label(); let tryEndLabel = new Label(); -- Gitee