diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeLabel.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeLabel.kt index 9bea6ad66eb..bab6e53952d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeLabel.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeLabel.kt @@ -34,11 +34,16 @@ class PseudocodeLabel internal constructor( override fun resolveToInstruction(): Instruction { val index = targetInstructionIndex - if (index < 0 || index >= instructionList.size) { - error("resolveToInstruction: incorrect index $index for label $name " + - "in subroutine ${correspondingElement.text} with instructions $instructionList") + when { + index < 0 -> + error("resolveToInstruction: unbound label $name " + + "in subroutine ${correspondingElement.text} with instructions $instructionList") + index >= instructionList.size -> + error("resolveToInstruction: incorrect index $index for label $name " + + "in subroutine ${correspondingElement.text} with instructions $instructionList") + else -> + return instructionList[index] } - return instructionList[index] } fun copy(newPseudocode: PseudocodeImpl, newLabelIndex: Int): PseudocodeLabel =