KT-1066 false 'Variable cannot be initialized before declaration'
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
//KT-1066 false 'Variable cannot be initialized before declaration'
|
||||
//+JDK
|
||||
|
||||
package kt1066
|
||||
|
||||
import java.util.Set
|
||||
|
||||
fun randomDigit() = 0.chr
|
||||
|
||||
fun foo(excluded: Set<Char>) {
|
||||
var digit : Char
|
||||
|
||||
do {
|
||||
digit = randomDigit()
|
||||
// ^^^^^ here!
|
||||
} while (excluded.contains(digit))
|
||||
}
|
||||
|
||||
fun test() {
|
||||
var sum : Int = 0
|
||||
var first : Int = 1
|
||||
var second : Int = 2
|
||||
var temp : Int //= 0 // variable 'temp' initializer is redundant
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (second > 4000000)
|
||||
break
|
||||
|
||||
if (second % 2 == 0)
|
||||
sum += second
|
||||
|
||||
temp = second
|
||||
second = first + second
|
||||
first = temp
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user