https://kotlinlang.org logo
#announcements
Title
# announcements
r

Ruckus

06/18/2019, 5:05 PM
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

streetsofboston

06/18/2019, 5:12 PM
It works for me…. it prints out the value
0
through `255`….
r

Ruckus

06/18/2019, 5:13 PM
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

streetsofboston

06/18/2019, 5:19 PM
I ran it using Android Studio, not on the kotlin playground
r

Ruckus

06/18/2019, 5:21 PM
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

streetsofboston

06/18/2019, 5:22 PM
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

Ruckus

06/18/2019, 5:23 PM
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

LS

06/18/2019, 5:23 PM
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

streetsofboston

06/18/2019, 5:24 PM
Weird that running it in Android Studio works fine….
r

Ruckus

06/18/2019, 5:24 PM
@streetsofboston Could you add that to the issue? That's good information to have.
s

streetsofboston

06/18/2019, 5:26 PM
Done 🙂
Also, I run it on a Mac
r

Ruckus

06/18/2019, 5:27 PM
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

streetsofboston

06/18/2019, 5:35 PM
When you replace UByte.MIN_VALUE and UByte.MAX_VALUE with 0 and 255, it works fine
r

Ruckus

06/18/2019, 5:36 PM
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

streetsofboston

06/18/2019, 5:37 PM
How do you get Kotlin 1.3.31… it doesn’t exist on my end…
r

Ruckus

06/18/2019, 5:38 PM
It was released in April (on the 25th), so IDEA just updated automatically a while ago
s

streetsofboston

06/18/2019, 5:40 PM
NVM… i was talking about Coroutines version…. 😕 🙂
r

Ruckus

06/18/2019, 5:40 PM
Ah 🙂
s

streetsofboston

06/18/2019, 5:43 PM
going to Kotlin 1.3.31 also shows the problem on my end
r

Ruckus

06/18/2019, 5:43 PM
Interesting, looks like it was a regression somewhere then.
2 Views