Hi all! Are you supposed to not store function in ...
# kotlin-native
w
Hi all! Are you supposed to not store function in variables when using kotlin-native? I’ve written a reducer function for reduxkotlin like this:
val splashReducer: Reducer<SplashState> =  { state, action -> return state }
and when I call it I have a EXC_BAD_ACCESS (code=1, address=0x0) error If I write the function like this:
fun splashReducer(state: SplashState, action: Any) : SplashState { return state }
it works! Do you think it’s a problem with reduxkotlin or with kotlin-native? P.S. On kotlin-android it works with both
a
A top level
val
can only be accessed from the main thread. Unless you annotated it with either
@SharedImmutable
or
@ThreadLocal
. As per https://kotlinlang.org/docs/reference/native/immutability.html Maybe this is the case?
w
I tried with both, but I don’t recall if the error changed or it was still the same.. I would expect an IncorrectDereferenceException in that case, but in the crash log the error is another. I’ll try once again to see what changes with that attributes, thanks!