diff --git a/ts2panda/src/compilerUtils.ts b/ts2panda/src/compilerUtils.ts index 42082fb7c2da751d22ea8b530ae884ee3de08ae3..01734351a4c0cd8a55162cf70c2ddaef4dcc687d 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();