KT-1066 false 'Variable cannot be initialized before declaration'

This commit is contained in:
svtk
2012-01-20 14:01:31 +04:00
parent 936a081bae
commit c09806da79
2 changed files with 50 additions and 7 deletions
@@ -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
}
}