CompilationException when labeling a method with Unit parameter?


Here is my code:

    fun loop(block: (Int, Parser) -> Unit) {
        for ((index, parser) in queue.withIndex())
            block(index, parser)
        label@ loop { index, parser ->
            parser.parseLine(event.getLine(index)) {
                if (it.cancelled) {
                // stuff

and for a parseLine it looks like this

abstract fun parseLine(line: String, block: (ParserCallback) -> Unit)

ParserCallback is just a data class

Probably I’m doing something wrong, but someone said that if I get CompilationException I should notify you guys about that… so I’m doing that. IntelliJ IDEA allows that syntax above, so I hoped it will work, but not necessarily.

I’m using Gradle with Kotlin 1.2.50.
I have a pretty short deadline so it would be AWESOME if someone could help me with that.

Also, I forgot, the error message:

PS: When I put label@ on parseLine function it still doesn’t work.


This looks more like a bug for the issue tracker

Did this work on the previous version?


I’ve tried it on 1.2.31 and it wasn’t working too


I can reproduce it. I simplified the code a bit

fun loop(block: (String) -> Unit){
	val data = listOf("foo", "bar", "baz")
	for (lines in data)

fun main(vararg args: String){
	lable@ loop{


See bug and related.

Basically, you should put label name before opening brace

loop label@ { index, parser ->