Uh oh!
There was an error while loading. Please reload this page.
gh-126835: Move constant unaryop & binop folding to CFG - #129550
Conversation
7140ad4 to
a6bababCompareUh oh!
There was an error while loading. Please reload this page.
| self.assert_ast(result_code, non_optimized_target, optimized_target) | ||
| def test_folding_match_case_allowed_expressions(self): | ||
| source = textwrap.dedent(""" |
There was a problem hiding this comment.
Do we also want to check for invalid expressions like duplicate mapping keys? For example:
matchx:
case {0j: y, 0j: z} ...There was a problem hiding this comment.
They won't trigger error here, this is only ast parsing phase. Error is emitted in codegen.
There was a problem hiding this comment.
yeah but it's not tested anywhere currently and since we're changing the logic around match, it feels safer to make sure we don't change something accidentally. Though I don't insist on adding it in this PR, it's more of a general comment
There was a problem hiding this comment.
We should test that, but I am not sure if in this PR as it only touches AST related logic.
There was a problem hiding this comment.
You can add tests covering various aspects of the feature you're touching.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
WolframAlph
commented
Feb 20, 2025
@iritkatriel CI reports unused functions, but we need them in assertions. So either mark them as used or convert them to macros I guess? |
iritkatriel
commented
Feb 20, 2025
Put them under |
…nary_expr only on debug builds
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I've addressed review & simplifed match pattern folding. One question remaining whether we should add tests with hand crafted ast with invalid expressions in match statement case. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
iritkatriel
commented
Feb 20, 2025
This is looking good. I made some final minor comments. Are you still planning to add tests for invalid hand-crafted ASTs? |
Done. Honestly I don't think we need them. We already test folding in match cases quite extensively, and current folding is the same as previous, just for limited expressions. We could add them for completeness, but probably in another PR as this one is getting quite big. But if you think we need them, I could add to this. |
iritkatriel
commented
Feb 21, 2025
Sure. |
iritkatriel
commented
Feb 21, 2025
It would be good to add smoke tests to make sure we don't crash on invalid ast input. Can be in another pr. |
WolframAlph
commented
Feb 21, 2025
Thanks @iritkatriel for guidance & patience. |
iritkatriel
commented
Feb 21, 2025
!buildbot refleak |
bedevere-bot
commented
Feb 21, 2025
🤖 New build scheduled with the buildbot fleet by @iritkatriel for commit cafbc61 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F129550%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
This PR migrates:
cc @Eclips4@tomasr8