krzema12 / kotlin-python

Python target for the Kotlin Programming Language. See https://github.com/krzema12/kotlin-python/tree/python-backend/python
https://discuss.kotlinlang.org/t/idea-python-backend/19852
48 stars 1 forks source link

Support some type checks #38

Closed SerVB closed 2 years ago

SerVB commented 2 years ago

Hey @krzema12, I see my testing was failing because a varying part wasn't removed:

-org.jetbrains.kotlin.python.test.ir.semantics.IrPythonCodegenBoxTestGenerated$Coroutines$SuspendFunctionAsCoroutine > testIfExpressionInsideCoroutine_1_3  Failed  KotlinCompilation   java.lang.IllegalStateException: org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl@... for VAR SYNTHESIZED_DECLARATION name:tmp type:kotlin.Unit [var] has unexpected parent org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl@a163eb
+org.jetbrains.kotlin.python.test.ir.semantics.IrPythonCodegenBoxTestGenerated$Coroutines$SuspendFunctionAsCoroutine > testIfExpressionInsideCoroutine_1_3  Failed  KotlinCompilation   java.lang.IllegalStateException: org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl@... for VAR SYNTHESIZED_DECLARATION name:tmp type:kotlin.Unit [var] has unexpected parent org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl@...

Do you think we can change @[a-f0-9]{7,8} to @[a-f0-9]{1,8} in the remover? I'm asking because you are the author of these lines and maybe there is a reason why you've decided to use {7,8} only. Indeed hashes less than 7 symbols are rare, but they can happen...

https://github.com/krzema12/kotlin-python/blob/80650cb95b8cd972e1c7e60f5a7cd7fae1bfdd13/python/experiments/generate-box-tests-reports.main.kts#L114

I'm rebasing to master now anyway so this rare problem will likely go away, but it can happen in the future.

krzema12 commented 2 years ago

@SerVB no problem, we can make the normalizing logic more generic. The @ sign that stands before the random part is itself pretty rare, so I'm not too afraid of some eager normalizations of places that shouldn't be normalized. Feel free to adjust as you suggest.