Use of uninitialized variables in lambdas / object literals / local functions is forbidden now #KT-4475 Fixed
Local declarations CFA: variable initialization information before them is now taken into account
This commit is contained in:
+11
-11
@@ -34,27 +34,27 @@ sink:
|
||||
}
|
||||
---------------------
|
||||
L3:
|
||||
3 <START> INIT: in: {} out: {}
|
||||
v(x: Int) INIT: in: {} out: {x=D}
|
||||
magic[FAKE_INITIALIZER](x: Int) -> <v0> INIT: in: {x=D} out: {x=D}
|
||||
w(x|<v0>) INIT: in: {x=D} out: {x=ID}
|
||||
4 mark(val y = x + a use(a)) INIT: in: {x=ID} out: {x=ID}
|
||||
v(val y = x + a) INIT: in: {x=ID} out: {x=ID, y=D} USE: in: {a=READ, x=READ} out: {a=READ, x=READ}
|
||||
r(x) -> <v1> INIT: in: {x=ID, y=D} out: {x=ID, y=D} USE: in: {a=READ} out: {a=READ, x=READ}
|
||||
3 <START> INIT: in: {a=ID, f=D} out: {a=ID, f=D}
|
||||
v(x: Int) INIT: in: {a=ID, f=D} out: {a=ID, f=D, x=D}
|
||||
magic[FAKE_INITIALIZER](x: Int) -> <v0> INIT: in: {a=ID, f=D, x=D} out: {a=ID, f=D, x=D}
|
||||
w(x|<v0>) INIT: in: {a=ID, f=D, x=D} out: {a=ID, f=D, x=ID}
|
||||
4 mark(val y = x + a use(a)) INIT: in: {a=ID, f=D, x=ID} out: {a=ID, f=D, x=ID}
|
||||
v(val y = x + a) INIT: in: {a=ID, f=D, x=ID} out: {a=ID, f=D, x=ID, y=D} USE: in: {a=READ, x=READ} out: {a=READ, x=READ}
|
||||
r(x) -> <v1> INIT: in: {a=ID, f=D, x=ID, y=D} out: {a=ID, f=D, x=ID, y=D} USE: in: {a=READ} out: {a=READ, x=READ}
|
||||
r(a) -> <v2>
|
||||
mark(x + a)
|
||||
call(x + a, plus|<v1>, <v2>) -> <v3>
|
||||
w(y|<v3>) INIT: in: {x=ID, y=D} out: {x=ID, y=ID} USE: in: {a=READ} out: {a=READ}
|
||||
r(a) -> <v4> INIT: in: {x=ID, y=ID} out: {x=ID, y=ID} USE: in: {} out: {a=READ}
|
||||
w(y|<v3>) INIT: in: {a=ID, f=D, x=ID, y=D} out: {a=ID, f=D, x=ID, y=ID} USE: in: {a=READ} out: {a=READ}
|
||||
r(a) -> <v4> INIT: in: {a=ID, f=D, x=ID, y=ID} out: {a=ID, f=D, x=ID, y=ID} USE: in: {} out: {a=READ}
|
||||
mark(use(a))
|
||||
call(use(a), use|<v4>) -> <v5>
|
||||
3 ret(*|<v5>) L4 INIT: in: {x=ID} out: {x=ID}
|
||||
3 ret(*|<v5>) L4 INIT: in: {a=ID, f=D, x=ID} out: {a=ID, f=D, x=ID}
|
||||
L4:
|
||||
<END>
|
||||
error:
|
||||
<ERROR> INIT: in: {} out: {}
|
||||
sink:
|
||||
<SINK> INIT: in: {x=ID} out: {x=ID} USE: in: {} out: {}
|
||||
<SINK> INIT: in: {a=ID, f=D, x=ID} out: {a=ID, f=D, x=ID} USE: in: {} out: {}
|
||||
=====================
|
||||
== use ==
|
||||
fun use(vararg a: Any?) = a
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
== bar ==
|
||||
fun bar(f: () -> Unit) = f()
|
||||
---------------------
|
||||
L0:
|
||||
1 <START> INIT: in: {} out: {}
|
||||
v(f: () -> Unit) INIT: in: {} out: {f=D}
|
||||
magic[FAKE_INITIALIZER](f: () -> Unit) -> <v0> INIT: in: {f=D} out: {f=D}
|
||||
w(f|<v0>) INIT: in: {f=D} out: {f=ID} USE: in: {f=READ} out: {f=READ}
|
||||
r(f) -> <v1> INIT: in: {f=ID} out: {f=ID} USE: in: {} out: {f=READ}
|
||||
mark(f())
|
||||
call(f(), invoke|<v1>) -> <v2>
|
||||
ret(*|<v2>) L1
|
||||
L1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR> INIT: in: {} out: {}
|
||||
sink:
|
||||
<SINK> INIT: in: {f=ID} out: {f=ID} USE: in: {} out: {}
|
||||
=====================
|
||||
== foo ==
|
||||
fun foo() {
|
||||
var v: Any
|
||||
bar { v.hashCode() }
|
||||
}
|
||||
---------------------
|
||||
L0:
|
||||
1 <START> INIT: in: {} out: {} USE: in: {} out: {}
|
||||
2 mark({ var v: Any bar { v.hashCode() } })
|
||||
v(var v: Any) INIT: in: {} out: {v=D}
|
||||
mark({ v.hashCode() }) INIT: in: {v=D} out: {v=D}
|
||||
jmp?(L2)
|
||||
d({ v.hashCode() }) USE: in: {v=READ} out: {v=READ}
|
||||
L2 [after local declaration]:
|
||||
r({ v.hashCode() }) -> <v0>
|
||||
mark(bar { v.hashCode() })
|
||||
call(bar { v.hashCode() }, bar|<v0>) -> <v1>
|
||||
L1:
|
||||
1 <END> INIT: in: {} out: {}
|
||||
error:
|
||||
<ERROR>
|
||||
sink:
|
||||
<SINK> USE: in: {} out: {}
|
||||
=====================
|
||||
== anonymous_0 ==
|
||||
{ v.hashCode() }
|
||||
---------------------
|
||||
L3:
|
||||
3 <START> INIT: in: {v=D} out: {v=D}
|
||||
4 mark(v.hashCode())
|
||||
mark(v.hashCode()) USE: in: {v=READ} out: {v=READ}
|
||||
r(v) -> <v0> USE: in: {} out: {v=READ}
|
||||
mark(hashCode())
|
||||
call(hashCode(), hashCode|<v0>) -> <v1>
|
||||
L4:
|
||||
3 <END>
|
||||
error:
|
||||
<ERROR> INIT: in: {} out: {}
|
||||
sink:
|
||||
<SINK> INIT: in: {v=D} out: {v=D} USE: in: {} out: {}
|
||||
=====================
|
||||
@@ -0,0 +1,6 @@
|
||||
fun bar(f: () -> Unit) = f()
|
||||
|
||||
fun foo() {
|
||||
var v: Any
|
||||
bar { v.hashCode() }
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
== bar ==
|
||||
fun bar(f: () -> Unit) = f()
|
||||
---------------------
|
||||
<v0>: {<: () -> Unit} NEW: magic[FAKE_INITIALIZER](f: () -> Unit) -> <v0>
|
||||
f <v1>: {<: () -> Unit} NEW: r(f) -> <v1>
|
||||
f() <v2>: Unit NEW: call(f(), invoke|<v1>) -> <v2>
|
||||
=====================
|
||||
== foo ==
|
||||
fun foo() {
|
||||
var v: Any
|
||||
bar { v.hashCode() }
|
||||
}
|
||||
---------------------
|
||||
{ v.hashCode() } <v0>: {<: () -> Unit} NEW: r({ v.hashCode() }) -> <v0>
|
||||
bar { v.hashCode() } <v1>: * NEW: call(bar { v.hashCode() }, bar|<v0>) -> <v1>
|
||||
{ var v: Any bar { v.hashCode() } } <v1>: * COPY
|
||||
=====================
|
||||
== anonymous_0 ==
|
||||
{ v.hashCode() }
|
||||
---------------------
|
||||
v <v0>: {<: Any} NEW: r(v) -> <v0>
|
||||
hashCode() <v1>: * NEW: call(hashCode(), hashCode|<v0>) -> <v1>
|
||||
v.hashCode() <v1>: * COPY
|
||||
v.hashCode() <v1>: * COPY
|
||||
=====================
|
||||
Reference in New Issue
Block a user