]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-128073: Include `EXIT_IF` when checking for escaping calls (GH-128537)
authorMark Shannon <mark@hotpy.org>
Mon, 6 Jan 2025 14:16:22 +0000 (14:16 +0000)
committerGitHub <noreply@github.com>
Mon, 6 Jan 2025 14:16:22 +0000 (14:16 +0000)
Lib/test/test_generated_cases.py
Tools/cases_generator/analyzer.py

index 9c65e81dfe4be18ffb4e1419c77a28b9918180ae..75cbd8dd94e9cb888beaa067e4f13a8a2deea893 100644 (file)
@@ -1713,6 +1713,31 @@ class TestGeneratedCases(unittest.TestCase):
         """
         self.run_cases_test(input, output)
 
+    def test_no_escaping_calls_in_branching_macros(self):
+
+        input = """
+        inst(OP, ( -- )) {
+            DEOPT_IF(escaping_call());
+        }
+        """
+        with self.assertRaises(SyntaxError):
+            self.run_cases_test(input, "")
+
+        input = """
+        inst(OP, ( -- )) {
+            EXIT_IF(escaping_call());
+        }
+        """
+        with self.assertRaises(SyntaxError):
+            self.run_cases_test(input, "")
+
+        input = """
+        inst(OP, ( -- )) {
+            ERROR_IF(escaping_call(), error);
+        }
+        """
+        with self.assertRaises(SyntaxError):
+            self.run_cases_test(input, "")
 
 class TestGeneratedAbstractCases(unittest.TestCase):
     def setUp(self) -> None:
index eca851e6de87aecf6eaaa97473c97e4c7acf2335..73c871759afbf50e05e68a638c9a63d7f4441255 100644 (file)
@@ -668,7 +668,7 @@ def check_escaping_calls(instr: parser.InstDef, escapes: dict[lexer.Token, tuple
         if tkn.kind == "IF":
             next(tkn_iter)
             in_if = 1
-        if tkn.kind == "IDENTIFIER" and tkn.text in ("DEOPT_IF", "ERROR_IF"):
+        if tkn.kind == "IDENTIFIER" and tkn.text in ("DEOPT_IF", "ERROR_IF", "EXIT_IF"):
             next(tkn_iter)
             in_if = 1
         elif tkn.kind == "LPAREN" and in_if: