Piotr Krzemiński
07/26/2021, 12:29 PMUnboundLocalError: local variable 'properties_initialized_utf8Encoding_kt' referenced before assignment
The lowering in question is PropertyLazyInitLowering.kt. Why it happens: the lowering produces initialization functions like
def init_properties_utf8Encoding_kt():
if not (properties_initialized_utf8Encoding_kt):
properties_initialized_utf8Encoding_kt = True
tmp0_byteArrayOf_0 = visitConst_other_Byte
REPLACEMENT_BYTE_SEQUENCE = tmp0_byteArrayOf_0
and before reaching if not (properties_initialized_utf8Encoding_kt):
, Python has to have properties_initialized_utf8Encoding_kt
assigned to some value (here False
would make sense). I wanted to add properties_initialized_utf8Encoding_kt = False
just before this function definition, but I'm lost in the structure of IR elements hierarchy. I cannot spot a place where the function is added to the IR output. Even if I use some transformers that compile fine, I don't see them do their job in the output. Could you help me figure it out?
Side-questions: are there any materials where I could learn more about the internal compiler API regarding IR entities, or only browsing the code is the way to go?SerVB
07/30/2021, 6:00 PMcompiler/testData/ir/irText
to understand which KT text goes to which IR, but I haven't tried it yet. And for the reverse direction, IR to KT, dumpKotlinLike
should help.
Regarding the first question, I have no idea, but if you want I can take a look too...Piotr Krzemiński
07/30/2021, 7:00 PMDeclarationTransformer
or IrElementTransformerVoid