From b57c02b0ba3c6f74fb0ad5f4cedd3967c066b3f8 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 31 Mar 2019 16:10:02 +0200 Subject: [PATCH] don't remove 'duplicate' assignments that aren't removable (i.e. not literalvalues) --- compiler/src/prog8/optimizing/StatementOptimizer.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/src/prog8/optimizing/StatementOptimizer.kt b/compiler/src/prog8/optimizing/StatementOptimizer.kt index 02ea4b609..91d712a79 100644 --- a/compiler/src/prog8/optimizing/StatementOptimizer.kt +++ b/compiler/src/prog8/optimizing/StatementOptimizer.kt @@ -20,7 +20,6 @@ import kotlin.math.floor todo inline subroutines that are only called a few times (3?) and that are "sufficiently small" (0-3 statements) todo analyse for unreachable code and remove that (f.i. code after goto or return that has no label so can never be jumped to) - */ class StatementOptimizer(private val namespace: INameScope, private val heap: HeapValues) : IAstProcessor { @@ -76,7 +75,7 @@ class StatementOptimizer(private val namespace: INameScope, private val heap: He var previousAssignmentLine: Int? = null for (i in 0 until statements.size) { val stmt = statements[i] as? Assignment - if (stmt != null) { + if (stmt != null && stmt.value is LiteralValue) { if (previousAssignmentLine == null) { previousAssignmentLine = i continue