| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
This PR adds ConditionalExpr support to `constant_fold_expr`
There was a problem hiding this comment.
Can you add an irbuild test and a run test?
Sorry, something went wrong.
|
Hmm that's weird, it looks like the constant for the base folded correctly, as did the 2 branch values, but not the overall expression ________________________ testConditionalConstantFolding ________________________
[gw3] linux -- Python 3.10.18 /home/runner/work/mypy/mypy/.tox/py/bin/python
data: /home/runner/work/mypy/mypy/mypyc/test-data/irbuild-constant-fold.test:482:
Failed: Invalid source code output (/home/runner/work/mypy/mypy/mypyc/test-data/irbuild-constant-fold.test, line 482)
----------------------------- Captured stderr call -----------------------------
Expected:
def f():
a :: str (diff)
L0:
a = "t" (diff)
Actual:
def f():
r0 :: bit (diff)
r1, r2, r3, a :: str (diff)
L0:
r0 = 2 != 0 (diff)
if r0 goto L1 else goto L2 :: bool (diff)
L1: (diff)
r1 = 't' (diff)
r2 = r1 (diff)
goto L3 (diff)
L2: (diff)
r3 = 'f' (diff)
r2 = r3 (diff)
L3: (diff)
a = r2 (diff)
return 1 (diff)
Alignment of first line difference:
E: a :: str
A: r0 :: bit
^
|
Sorry, something went wrong.
|
I mean... I guess it did constant fold all of the necessary values... And I think with the code like this the C compiler can optimize away the if check in some cases (ex: ints), but not all (ex: strings) |
Sorry, something went wrong.
|
Oh, I know why! Let's put this on hold until #19982 is merged, so I can use the @folding_candidate decorator |
Sorry, something went wrong.
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This PR adds ConditionalExpr support to constant_fold_expr