Closed JSAbrahams closed 1 year ago
Hm what about functions which have code blocks as a body but which should be treated as an expression. I.e.:
def my_var := if cond then
print("then")
10
else
print("else")
20
This should then become the following python code:
if cond then
print("then")
my_var = 10
else
print("else")
my_var = 20
Before merging, it'd be nice actually to check other situations where an if expression should be converted to a Python ternary expression. Currently, we only do this within a function argument. What about using an (inline-)if expressions for:
I suspect it will work in these situations as well (and it should, we want to be as generic as possible here!). But alas the project has reached a level of complexity where I can't accurately predict if it will, so we must test.
Merging #364 (b52c7e1) into develop (b12963b) will increase coverage by
0.06%
. The diff coverage is92.01%
.
@@ Coverage Diff @@
## develop #364 +/- ##
===========================================
+ Coverage 86.99% 87.06% +0.06%
===========================================
Files 108 108
Lines 11727 11965 +238
===========================================
+ Hits 10202 10417 +215
- Misses 1525 1548 +23
Looking at codecov, few notes:
let-else
instead: https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html?
Though this doesn't actually fix the panic issue.
Relevant issues
Closes #164 Should've been a separate issue but couldn't be bothered to create one.
Introduced bug highlighted in #366 . Discovered bug highlighted in #367
Summary
Treat if expressions as expressions where relevant by converting them to python ternary expressions.
ExpressionAny
, which introduced a lot of unnecessary logic and complexity. Streamlining of logic made it easier to implement this new feature. Instead, just have a dedicatedAny
type and match this if needed. (Perhaps this introduced the bug in #366?).Added Tests