Skip to content

Commit 67bbe81

Browse files
committed
Fix patma guard
1 parent 4f51bd5 commit 67bbe81

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

Lib/test/test_patma.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,6 @@ def test_patma_051(self):
586586
self.assertEqual(y, 1)
587587
self.assertEqual(z, 0)
588588

589-
@unittest.expectedFailure # TODO: RUSTPYTHON
590589
def test_patma_052(self):
591590
x = [1, 0]
592591
match x:
@@ -1904,7 +1903,6 @@ def whereis(points):
19041903
self.assertEqual(whereis([Point(0, 0), Point(0, 0), Point(0, 0)]), "Something else")
19051904
self.assertEqual(whereis([Point(0, 1), Point(0, 1), Point(0, 1)]), "Something else")
19061905

1907-
@unittest.expectedFailure # TODO: RUSTPYTHON
19081906
def test_patma_183(self):
19091907
def whereis(point):
19101908
match point:
@@ -2695,7 +2693,6 @@ def f(self, x):
26952693
setattr(c, "__attr", "spam") # setattr is needed because we're in a class scope
26962694
self.assertEqual(Outer().f(c), "spam")
26972695

2698-
@unittest.expectedFailure # TODO: RUSTPYTHON
26992696
def test_patma_250(self):
27002697
def f(x):
27012698
match x:
@@ -2707,7 +2704,6 @@ def f(x):
27072704
self.assertIs(f({"foo": 1}), True)
27082705
self.assertIs(f({"foo": -1}), False)
27092706

2710-
@unittest.expectedFailure # TODO: RUSTPYTHON
27112707
def test_patma_251(self):
27122708
def f(v, x):
27132709
match v:
@@ -2726,7 +2722,6 @@ def __init__(self, attr):
27262722
self.assertIs(f(-1, X(-1)), False)
27272723
self.assertIs(f(1, X(-1)), None)
27282724

2729-
@unittest.expectedFailure # TODO: RUSTPYTHON
27302725
def test_patma_252(self):
27312726
# Side effects must be possible in guards:
27322727
effects = []
@@ -2764,7 +2759,6 @@ def f(v):
27642759
self.assertEqual(f(1), 1)
27652760
self.assertEqual(f({"x": 1}), 1)
27662761

2767-
@unittest.expectedFailure # TODO: RUSTPYTHON
27682762
def test_patma_255(self):
27692763
x = []
27702764
match x:

compiler/codegen/src/compile.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4011,10 +4011,10 @@ impl Compiler {
40114011
self.ensure_fail_pop(pattern_context, 0)?;
40124012
// Compile the guard expression
40134013
self.compile_expression(guard)?;
4014-
// If guard is false, jump to fail_pop[0]
4014+
emit!(self, Instruction::ToBool);
40154015
emit!(
40164016
self,
4017-
Instruction::JumpIfFalseOrPop {
4017+
Instruction::PopJumpIfFalse {
40184018
target: pattern_context.fail_pop[0]
40194019
}
40204020
);

0 commit comments

Comments
 (0)