Does semantics of `undefined` changed in Kotlin 2....
# javascript
r
Does semantics of
undefined
changed in Kotlin 2.0.0? The compiler gives me
SENSELESS_COMPARISON
warning when comparing an object of not nullable type with
undefined
.
😜 1
🆒 1
t
Cool warning. Such comparison has no sense in fact.
r
It gives a warning but works OK.
If you remove a comparison with
undefined
the warning is gone but the function doesn't work correctly.
t
You wrote about non-nullable type in initial message :)
r
It's non-nullable after first condition.
t
No :)
In JS - no, that is problem :(
r
I know that, but the compiler should know that as well ...
Being forced to add sensless comparision suppression is not nice at all ;]
I have added 7 of them in KVision codebase. I don't have time to re-check all these places and analyze if my
undefined
comparisons are correct or not. When I see that the compiler is definitely wrong in one place, I prefer to trust that I wrote the right code in other places.
t
In your example you can use
this == null
It will check both
null
and
undefined
e
@Robert Jaros suppression will stop working soon. I really really encourage people to open issues when suppressions are involved
r
Where did this information come from?
e
https://youtrack.jetbrains.com/issue/KT-24783/ There is still a plan to allow SOME suppressions with compiler options, but you should make them aware of your use cases.
If yours is a warning tho, you should be safe.
r
It's hard to live without suppressing errors with JS externals ...
e
Yup! So that's why I've already reported a couple. If you think you need a suppression, I think it's still worth making it obvious in an issue. https://youtrack.jetbrains.com/issue/KT-68632/ https://youtrack.jetbrains.com/issue/KT-68637/