Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle and and or #148

Open
sklam opened this issue Sep 4, 2024 · 3 comments · May be fixed by #165
Open

Handle and and or #148

sklam opened this issue Sep 4, 2024 · 3 comments · May be fixed by #165

Comments

@sklam
Copy link
Member

sklam commented Sep 4, 2024

Desugar and and or into control-flow constructs so that they are handled in the SCFG

@esc
Copy link
Member

esc commented Sep 26, 2024

@esc
Copy link
Member

esc commented Jan 27, 2025

co-pilot suggests this test case:

diff --git i/numba_rvsdg/tests/test_ast_transforms.py w/numba_rvsdg/tests/test_ast_transforms.py
index bfc7dc08df..fc09927927 100644
--- i/numba_rvsdg/tests/test_ast_transforms.py
+++ w/numba_rvsdg/tests/test_ast_transforms.py
@@ -1227,6 +1227,31 @@ class TestAST2SCFGTransformer(TestCase):
             arguments=arguments,
         )

+    def test_and(self):
+        def function(x: int, y: int) -> int:
+            if x and y:
+                return 0
+            return 1
+
+        expected = {
+            "0": {
+                "instructions": ["x == 0", "y == 0"],
+                "jump_targets": ["1", "2"],
+                "name": "0",
+            },
+            "1": {
+                "instructions": ["return 0"],
+                "jump_targets": [],
+                "name": "1",
+            },
+            "2": {
+                "instructions": ["return 1"],
+                "jump_targets": [],
+                "name": "2",
+            },
+        }
+        self.compare(function, expected, arguments=[(0, 0), (0, 1), (1, 0)])
+

 class TestEntryPoints(TestCase):

@esc
Copy link
Member

esc commented Jan 27, 2025

The CFG that is constructed looks like:

Image

but this is not de-sugared, need to figure out what de-sugaring means in this context

@esc esc linked a pull request Jan 28, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants