Is it a known bug that this terminates at `UInt.MA...
# announcements
r
Is it a known bug that this terminates at
UInt.MAX_VALUE
instead of
UByte.MAX_VALUE
?
Copy code
fun main() {
    for (x in UByte.MIN_VALUE..UByte.MAX_VALUE) {
        println(x)
    }
}
s
It works for me…. it prints out the value
0
through `255`….
r
Really? keeps right on going and printing values up to
UInt.MAX_VALUE
for me.
Running it in https://pl.kotl.in/H_6davVCu has some really weird behavior. It runs the previously entered program, and doesn't actually run this one...
s
I ran it using Android Studio, not on the kotlin playground
r
I tried it both in IntelliJ and in the playground. In intelliJ it goes up to
UInt.MAX_VALUE
, and the playground does what I mentioned above (try clicking it and see if you get the same as I)
I decided to file a bug. We'll see if anyone else can reproduce it: https://youtrack.jetbrains.com/issue/KT-32044?project=kt
s
How long does it take until it gets to UInt.MAX_VALUE?
It works on Android Studio; I tried Kotlin version 1.2.1 and 1.3.0-M1
r
A long time. You can shorten it by removing the `println`:
Copy code
fun main() {
    var n = 0u
    for (x in UByte.MIN_VALUE..UByte.MAX_VALUE) {
        n = x
    }
    println(n)
}
That returns quickly and prints
UInt.MAX_VALUE
l
I tried it in IntelliJ and got the same (unexpected) result, but the IDE screams about unsigned types being experimental, so I guess bugs are to be expected
s
Weird that running it in Android Studio works fine….
r
@streetsofboston Could you add that to the issue? That's good information to have.
s
Done 🙂
Also, I run it on a Mac
r
Sweet, thanks
I guess I should add what I'm running on to the issue., but I'm on Windows 10 using IntelliJ 2019.1.3 and Kotlin 1.3.31
Hmm, changing the playground to use JS appears to fix the issue too...
s
When you replace UByte.MIN_VALUE and UByte.MAX_VALUE with 0 and 255, it works fine
r
Indeed, it has to be when you use the constants for some reason. I'm not sure if it has something to do with the constants themselves, or with the fact that
x
gets converted to
UInt
.
s
How do you get Kotlin 1.3.31… it doesn’t exist on my end…
r
It was released in April (on the 25th), so IDEA just updated automatically a while ago
s
NVM… i was talking about Coroutines version…. 😕 🙂
r
Ah 🙂
s
going to Kotlin 1.3.31 also shows the problem on my end
r
Interesting, looks like it was a regression somewhere then.