diff --git a/pyre2/pyre2/bin/binding/bindings.rs b/pyre2/pyre2/bin/binding/bindings.rs index 9354f3303e..3aaea953d3 100644 --- a/pyre2/pyre2/bin/binding/bindings.rs +++ b/pyre2/pyre2/bin/binding/bindings.rs @@ -652,7 +652,7 @@ impl<'a> BindingsBuilder<'a> { let narrow_ops = NarrowOps::from_expr(Some((*x.test).clone())); self.bind_narrow_ops(&narrow_ops, x.body.range()); self.ensure_expr(&x.body); - self.negate_and_merge_flow(base, &narrow_ops, Some(&x.orelse), x.orelse.range()); + self.negate_and_merge_flow(base, &narrow_ops, Some(&x.orelse), x.range()); return; } Expr::BoolOp(ExprBoolOp { range, op, values }) => { diff --git a/pyre2/pyre2/bin/test/flow.rs b/pyre2/pyre2/bin/test/flow.rs index 10754a77c1..17e100f5d1 100644 --- a/pyre2/pyre2/bin/test/flow.rs +++ b/pyre2/pyre2/bin/test/flow.rs @@ -858,3 +858,12 @@ def f(x: None): pass "#, ); + +// Regression test for a crash +testcase!( + test_ternary_and_or, + r#" +def f(x: bool, y: int): + return 0 if x else (y or 1) + "#, +);