| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3151,6 +3151,19 @@ def f(command): # 0 | |||
| 3151 | 3151 | self.assertListEqual(self._trace(f, "go x"), [1, 2, 3]) | |
| 3152 | 3152 | self.assertListEqual(self._trace(f, "spam"), [1, 2, 3]) | |
| 3153 | 3153 | ||
| 3154 | + def test_unreachable_code(self): | ||
| 3155 | + def f(command): # 0 | ||
| 3156 | + match command: # 1 | ||
| 3157 | + case 1: # 2 | ||
| 3158 | + if False: # 3 | ||
| 3159 | + return 1 # 4 | ||
| 3160 | + case _: # 5 | ||
| 3161 | + if False: # 6 | ||
| 3162 | + return 0 # 7 | ||
| 3163 | + | ||
| 3164 | + self.assertListEqual(self._trace(f, 1), [1, 2, 3]) | ||
| 3165 | + self.assertListEqual(self._trace(f, 0), [1, 2, 5, 6]) | ||
| 3166 | + | ||
| 3154 | 3167 | def test_parser_deeply_nested_patterns(self): | |
| 3155 | 3168 | # Deeply nested patterns can cause exponential backtracking when parsing. | |
| 3156 | 3169 | # See gh-93671 for more information. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + Fix an issue where incorrect locations numbers could be assigned to code following ``case`` blocks. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7057,6 +7057,7 @@ compiler_match_inner(struct compiler *c, stmt_ty s, pattern_context *pc) | |||
| 7057 | 7057 | ADDOP(c, POP_TOP); | |
| 7058 | 7058 | } | |
| 7059 | 7059 | VISIT_SEQ(c, stmt, m->body); | |
| 7060 | + UNSET_LOC(c); | ||
| 7060 | 7061 | ADDOP_JUMP(c, JUMP, end); | |
| 7061 | 7062 | // If the pattern fails to match, we want the line number of the | |
| 7062 | 7063 | // cleanup to be associated with the failed pattern, not the last line | |
@@ -7081,6 +7082,7 @@ compiler_match_inner(struct compiler *c, stmt_ty s, pattern_context *pc) | |||
| 7081 | 7082 | RETURN_IF_FALSE(compiler_jump_if(c, m->guard, end, 0)); | |
| 7082 | 7083 | } | |
| 7083 | 7084 | VISIT_SEQ(c, stmt, m->body); | |
| 7085 | + UNSET_LOC(c); | ||
| 7084 | 7086 | } | |
| 7085 | 7087 | compiler_use_next_block(c, end); | |
| 7086 | 7088 | return 1; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments