From f9e22add033ee41eb42d5f391b71b3de646a2067 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sat, 30 Oct 2021 15:15:00 +0200 Subject: [PATCH] fix crash when using array as paramater type --- compiler/src/prog8/compiler/astprocessing/LiteralsToAutoVars.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/src/prog8/compiler/astprocessing/LiteralsToAutoVars.kt b/compiler/src/prog8/compiler/astprocessing/LiteralsToAutoVars.kt index cd1ceaf21..1eb039a42 100644 --- a/compiler/src/prog8/compiler/astprocessing/LiteralsToAutoVars.kt +++ b/compiler/src/prog8/compiler/astprocessing/LiteralsToAutoVars.kt @@ -41,6 +41,8 @@ internal class LiteralsToAutoVars(private val program: Program) : AstWalker() { // this array literal is part of an expression, turn it into an identifier reference val litval2 = array.cast(arrayDt.getOr(DataType.UNDEFINED)) if(litval2!=null) { + if(array.parent !is IStatementContainer) + return noModifications val vardecl2 = VarDecl.createAuto(litval2) val identifier = IdentifierReference(listOf(vardecl2.name), vardecl2.position) return listOf(