Files
kotlin-fork/compiler/testData/cfg-variables/lexicalScopes/localFunctionScopeWithoutBody.instructions
T
Mikhail Glukhikh fe13f39de9 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
2015-11-17 18:21:09 +03:00

48 lines
2.2 KiB
Plaintext
Vendored

== foo ==
fun foo() {
"before"
val b = 1
fun local(x: Int) = x + b
"after"
}
---------------------
L0:
1 <START> INIT: in: {} out: {} USE: in: {} out: {}
2 mark({ "before" val b = 1 fun local(x: Int) = x + b "after" })
mark("before")
r("before") -> <v0>
v(val b = 1) INIT: in: {} out: {b=D}
r(1) -> <v1> INIT: in: {b=D} out: {b=D}
w(b|<v1>) INIT: in: {b=D} out: {b=ID}
jmp?(L2) INIT: in: {b=ID} out: {b=ID}
d(fun local(x: Int) = x + b) USE: in: {b=READ} out: {b=READ}
L2 [after local declaration]:
mark("after")
r("after") -> <v2>
L1:
1 <END> INIT: in: {} out: {}
error:
<ERROR>
sink:
<SINK> USE: in: {} out: {}
=====================
== local ==
fun local(x: Int) = x + b
---------------------
L3:
3 <START> INIT: in: {b=ID} out: {b=ID}
v(x: Int) INIT: in: {b=ID} out: {b=ID, x=D}
magic[FAKE_INITIALIZER](x: Int) -> <v0> INIT: in: {b=ID, x=D} out: {b=ID, x=D}
w(x|<v0>) INIT: in: {b=ID, x=D} out: {b=ID, x=ID} USE: in: {b=READ, x=READ} out: {b=READ, x=READ}
r(x) -> <v1> INIT: in: {b=ID, x=ID} out: {b=ID, x=ID} USE: in: {b=READ} out: {b=READ, x=READ}
r(b) -> <v2> USE: in: {} out: {b=READ}
mark(x + b)
call(x + b, plus|<v1>, <v2>) -> <v3>
ret(*|<v3>) L4
L4:
<END>
error:
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {b=ID, x=ID} out: {b=ID, x=ID} USE: in: {} out: {}
=====================