SerVB
07/19/2021, 10:35 AMPiotr Krzemiński
07/21/2021, 7:27 AMvisitField(declaration: IrField...
, branch translate-field-declarations), however it's tricky because in Python to be able to use some function, it has to be first defined. That's why now all box tests fail with:
Traceback (most recent call last):
File "/home/piotr/repos/kotlin-python/python/py.translator/testData/out/codegen/irBox/when/noElseInStatement_v5.py4568195347954504164/consumer.py", line 1, in <module>
from compiled_module import box
File "/home/piotr/repos/kotlin-python/python/py.translator/testData/out/codegen/irBox/when/noElseInStatement_v5.py4568195347954504164/compiled_module.py", line 1356, in <module>
UNDEFINED_RESULT = UNDEFINED_RESULT_init_()
NameError: name 'UNDEFINED_RESULT_init_' is not defined
TODO: I think we need to do a similar thing that is done for JavaScript - move field assignments to the bottom, or reorder stuff in some other smart way. Leaving my work-in-progress change on the branch in case someone wants to tackle this problem. If not, I'll get back to it in a few daysPiotr Krzemiński
07/22/2021, 9:25 AMjsNot
(probably in favor of Python's not
)😄 IrComposite
is another thing to cover. Once we have these two, the property initializers should work properly and I expect a nice bump in the number of passed box tests. Details in the PR: Translate property declaration and initialization by krzema12 · Pull Request #12 · krzema12/kotlin-pythonSerVB
07/23/2021, 4:49 PMPiotr Krzemiński
07/24/2021, 4:36 PMSerVB
07/26/2021, 10:37 AMv1.5.21
of the Kotlin repo and since this tag is merged to Kotlin/Py, we now have this same problem too. This doesn't affect code writing though: completion still works normally. Just a button "imprort Gradle changes" is always visible in IDEA.
Piotr experiences a similar issue too.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, 2:13 PMPiotr Krzemiński
08/05/2021, 11:48 AMSerVB
08/06/2021, 6:46 PM._and
, .xor
, .equals
instead of plain operators: research why.
• Maybe something else related to signed integers, but for now I don't see other tasks here.
• Maybe start with unsigned integers.SerVB
08/13/2021, 6:26 PMbinaryOp/call
have lambdas that we can't compile for now. I want to switch my context a bit and try to support lambdas.Piotr Krzemiński
08/14/2021, 11:39 AMPiotr Krzemiński
08/20/2021, 11:32 AMSerVB
08/20/2021, 4:07 PMPiotr Krzemiński
08/26/2021, 6:36 AMcontext.getNameFor...
to calculate a name for a function or a variable. We currently ignore it, which results in such behavior. In our simple failure root cause report▾
RecursionError: maximum recursion depth exceeded
. The linked code hints me that it also has an indirect influence on issues that occur more frequently, like NameError: name 'Companion_instance' is not defined
. I think we should work on this next. It's also needed to go forward with my Translate property declaration and initialization by krzema12 · Pull Request #12 · krzema12/kotlin-python.
@SerVB do you fancy taking a closer look tomorrow, or you'd rather tackle another problem?
My next slot for working on kotlin-python will be in 2 weeks.SerVB
08/27/2021, 2:43 PMbox-tests-report.tsv
has a problem having it in the repo: it contains unstable values like execution time and sometimes paths to temporary files with random names (in stacktraces).
So we are risking to have many changed lines in each PR...
Anyway, it doesn't seem very critical to meSerVB
08/27/2021, 6:25 PMSerVB
09/03/2021, 2:07 PMSerVB
09/03/2021, 5:47 PMPiotr Krzemiński
09/04/2021, 5:45 AMprintln("Hello world!")
work 🙂 now there's some issue with property initialization, output
is not defined. In JS version the initializer function is executed at the very end. Maybe we should get back to lazily initiated properties, so I'll try to rebase my still-as-draft PR from a month ago and see if it helps. @SerVB I remember some TODO from your recent PRs that could address this. Is it in scope that you worked on yesterday and didn't send to review yet?SerVB
09/04/2021, 11:33 AMSerVB
09/10/2021, 6:14 PMSerVB
09/10/2021, 6:55 PMout-pir
dir stops to be generated during box testingPiotr Krzemiński
09/16/2021, 8:29 PMNameError: name 'Object_create' is not defined
, it's top 1 of box tests failure reasonsSerVB
09/24/2021, 10:58 PMSerVB
10/01/2021, 4:56 PMSerVB
10/01/2021, 8:05 PMSerVB
10/08/2021, 6:42 PM__new__
, so was able to implement Python-compatible variant of Object_create
intrinsic. Looks like the current state is working, but maybe we could make compilation more python-ish in the future if we want. +47 box tests pass (we have 1999/5787 passing now 😅).
Next time:
• Maybe some more unimplemented intrinsics.
• Continue with IrTry but there can be some more blockers on the way.Piotr Krzemiński
10/13/2021, 8:30 AMSerVB
10/15/2021, 12:12 PMSerVB
10/15/2021, 12:12 PMPiotr Krzemiński
10/15/2021, 12:13 PM