Getting an error compiling my code (file in thread...
# kotlin-native
m
Getting an error compiling my code (file in thread)
Copy code
e: org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
      File being compiled: /home/mart/git/kaudio-python/src/nativeMain/kotlin/kaudio/nodes/util/InputNode.kt
      The root cause java.lang.IllegalArgumentException was thrown at: org.jetbrains.kotlin.backend.konan.lower.InteropTransformer.visitCall(InteropLowering.kt:1117)
          at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException(CodegenUtil.kt:238)
          at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException$default(CodegenUtil.kt:234)
          at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invokeSequential(performByIrFile.kt:68)
Copy code
package kaudio.nodes.util

import kaudio.FRAME_SIZE
import kaudio.nodes.base.DualNode
import kotlinx.cinterop.convert
import kpy.annotations.PyExport

@PyExport
class InputNode(stereo: Boolean) : DualNode(stereo) {
    private val bufLeft by python(FloatArray(FRAME_SIZE) { 0f }) {
        if (it.size != FRAME_SIZE.convert()) {
            throw IllegalArgumentException("Buffer size must be of size $FRAME_SIZE")
        }
    }
    private val bufRight by python(FloatArray(FRAME_SIZE) { 0f }) {
        if (it.size != FRAME_SIZE.convert()) {
            throw IllegalArgumentException("Buffer size must be of size $FRAME_SIZE")
        }
    }
    private val buffer by python(FloatArray(FRAME_SIZE) { 0f }) {
        if (it.size != FRAME_SIZE.convert()) {
            throw IllegalArgumentException("Buffer size must be of size $FRAME_SIZE")
        }
    }

    init {
        if (stereo) {
            removeInput(::input)
            removeProperty(::buffer)
        } else {
            removeInput(::inputLeft)
            removeInput(::inputRight)
            removeProperty(::bufLeft)
            removeProperty(::bufRight)
        }
    }

    override fun processStereo() {
        bufLeft.copyInto(outputLeft)
        bufRight.copyInto(outputRight)
    }

    override fun processMono() {
        buffer.copyInto(output)
    }
}
a
Please try to find the exact line in the file that is causing the compiler to crash, then rewrite this code in some other way to make it compile. Also, please report an issue at https://youtrack.jetbrains.com/issues/KT with a sample project (self-contained code sample) to reproduce and a full stacktrace.