Kotlin: [Internal Error] org.jetbrains.kotlin.backend.common.BackendException: Backend Internal

created at 03-21-2022 views: 37

problem

When I debugged the code in IDEA today, I encountered a problem. When IDEA wrote the code, the code was not marked in red and reported an error, but after running and compiling, it would fail and report an error:

Kotlin: [Internal Error] org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering

Part of my code is as follows:

fun main() {
}

class Solution {
        if (word == "") {
            return true
        }
        if (board.size == 0 || board[0].size == 0) {
            return false
        }
        for (x in 0..board.size - 1) {
            for (y in 0..board[0].size - 1) {
                if (board[x][y] == word.get(0)) {
                    if (exist(board, word, 0, Array(board.size){BooleanArray(board[0].size, return false)}, x, y)) { return true }
                }
            }
        }

        return false
    }


    fun exist(board: Array<CharArray>, word: String, index : Int, hasInclude : Array<BooleanArray>, x : Int, y : Int) : Boolean {
        if (index == word.length) {
            return true
        }
        if (x < 0 || x >= board.size || y < 0 || y >= board[0].size || hasInclude[x][y]) {
            return false
        }
        if (board[x][y] == word.get(index)) {
            hasInclude[x][y] = true
            val ans = exist(board, word, index + 1, hasInclude, x + 1, y) || exist(board, word, index + 1, hasInclude, x - 1, y) || exist(board, word, index + 1, hasInclude, x, y + 1) || exist(board, word, index + 1, hasInclude, x, y - 1)
            hasInclude[x][y] = false
            return ans
        }

        return false
    }
}

solution

The problem lies in the wrong use of the functional interface (the landlord will not use the functional formula, but I guessed that I wrote it, and IDEA did not report an error, I thought I wrote it correctly... The running error is not the report that the code here is wrong. ..), the error looks like this:

error code

error code

example of modification:

solution

created at:03-21-2022
edited at: 03-21-2022: