Skip to content

Commit

Permalink
Modify yields to carry yield expressions instead of expressions
Browse files Browse the repository at this point in the history
Summary:
Cleaning up the implementation so that yields can be a list of yield expressions.

Clean up some redundant functions as well

Reviewed By: ndmitchell

Differential Revision: D67684633

fbshipit-source-id: 96f76b22e3cf2ef106466bb8e6d6cc07033d63e6
  • Loading branch information
migeed-z authored and facebook-github-bot committed Dec 31, 2024
1 parent bc40734 commit 5d90da9
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions pyre2/pyre2/bin/binding/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use ruff_python_ast::ExprLambda;
use ruff_python_ast::ExprName;
use ruff_python_ast::ExprNoneLiteral;
use ruff_python_ast::ExprSubscript;
use ruff_python_ast::ExprYield;
use ruff_python_ast::Identifier;
use ruff_python_ast::Parameters;
use ruff_python_ast::Pattern;
Expand Down Expand Up @@ -137,7 +138,7 @@ struct BindingsBuilder<'a> {
/// Accumulate all the return statements
returns: Vec<StmtReturn>,
/// Accumulate all the yield statements
yields: Vec<Expr>,
yields: Vec<ExprYield>,
table: BindingTable,
}

Expand Down Expand Up @@ -638,8 +639,8 @@ impl<'a> BindingsBuilder<'a> {
self.bind_lambda(x);
true
}
Expr::Yield(_) => {
self.yields.push(x.clone());
Expr::Yield(y) => {
self.yields.push(y.clone());
false
}
_ => false,
Expand Down Expand Up @@ -2070,12 +2071,9 @@ fn return_expr(x: StmtReturn) -> Expr {
}
}

fn yield_expr(x: Expr) -> Expr {
match x {
Expr::Yield(x) => match x.value {
Some(x) => *x,
None => Expr::NoneLiteral(ExprNoneLiteral { range: x.range() }),
},
_ => Expr::NoneLiteral(ExprNoneLiteral { range: x.range() }),
fn yield_expr(x: ExprYield) -> Expr {
match x.value {
Some(x) => *x,
None => Expr::NoneLiteral(ExprNoneLiteral { range: x.range }),
}
}

0 comments on commit 5d90da9

Please sign in to comment.