Are returns inside composable currently bugged (al...
# compose
y
Are returns inside composable currently bugged (alpha07)? I'm getting a lot of
java.lang.IllegalStateException: Start/end imbalance
when using them Wrapping the whole follow code into a conditional block instead fixes the issue
r
@Leland Richardson [G]
l
We haven’t seen any issues - can you create a simple repro? This could be a runtime issue or a compiler issue
y
No problem, will try to do that this weekend
a
I also encountered this error as well.. I had a composable:
Copy code
@Composable
fun MyComposable(
    myStateList: List<MyState>, 
    ...,
) {
    // ------- This here is causing the error
    val transformedMyState = myStateList.map {
        myTransformation(it)
    }
    // ------- Removing the code above, also removes the error
    LazyRowForIndexed(transformedMyState) {
        ...
    }
}
It was perfectly working on
alpha06
and only encountered the error after migrating to
alpha07
. So in the end I settled to:
Copy code
@Composable
fun MyComposable(
    myStateList: List<MyState>, 
    ...,
) {
    LazyRowForIndexed(
        myStateList.map {
            myTransformation(it)
        }
    ) {
        ...
    }
}
I then no longer get the error... 🤔
l
wow, that’s pretty curious
can you file a big with the full code to repro?
based on your observation it seems likely that there’s some compiler related issue here
a
Will try and recreate it... ill do after work and share the link here...
l
thank you
a
Hi @Leland Richardson [G], I'm unsuccessful in recreating the error.. it seems that the error wasn't cause by the things I mentioned above... hmmm... I would try and backtrack my changes..
y
@Leland Richardson [G] Sorry for the delay, I managed to reproduce it with the following minified snippet:
Copy code
@Composable
fun BuggedComposable(
) {
    Surface {
        Box(modifier = Modifier.fillMaxSize()) {
            val state = mutableStateOf<String?>(null)
            val title = state.value ?: return@Box
        }
    }
}
Removing the
?: return@Box
fixes the crash. Do you want me to file a bug with this? (Using alpha07 and kotlin 1.4.0)
(Funny observation, removing the wrapping Box also avoids the crash, so I'm guessing a certain level of nesting is necessary before having the crash?)
l
oh, nice. thanks so much for this repro
if you could file a bug that would be great
if not, i can file one on your behalf
y
will do
l
thank you!
👍 1
y
Any news on this @Leland Richardson [G] ?
(Just FYI, still happening on alpha12)
p
Again happening on 1.4