https://kotlinlang.org logo
t

Ties

04/04/2022, 2:04 PM
In doing some experimentation I found something that is not very intuative:
Copy code
@JvmInline
value class String5till10(val value: String) {
	init {
		require(value.length >= 5) { "String should be minimal 5 characters" }
		require(value.length <= 10) { "String should be maximum 10 characters" }
	}
}


// This works
val value = getRandomString()
if (value.length > 6) {
	if (value.length < 10) {
		StringExamples.String5till10(value)
	}
}

//This does not
val value = getRandomString()
if (value.length > 6 && value.length < 10) {
	StringExamples.String5till10(value)
}
a

Alejandro Serrano Mena

04/04/2022, 2:13 PM
this is definitely a bug
I guess the transformation of conditionals into internal constraints is not working as it should with
&&
t

Ties

04/04/2022, 2:14 PM
Ill make a bug report then 🙂
a

Alejandro Serrano Mena

04/04/2022, 2:14 PM
t

Ties

04/04/2022, 2:15 PM
I guess i will not make a bug report then 🙂
a

Alejandro Serrano Mena

04/04/2022, 7:45 PM
new stable version 2.0.2 released with that bugfix!
4 Views