-
Notifications
You must be signed in to change notification settings - Fork 0
Fix: [for cherry-picking] Updated suspension walkers to inspect call/ne #200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7055,6 +7055,7 @@ fn count_yields(expression: &Expr) -> u32 { | |||||||||||||||||||
| .iter() | ||||||||||||||||||||
| .map(|argument| match argument { | ||||||||||||||||||||
| CallArgument::Expression(value) => count_yields(value), | ||||||||||||||||||||
| CallArgument::Spread(spread) => count_yields(&spread.argument), | ||||||||||||||||||||
| _ => 0, | ||||||||||||||||||||
| }) | ||||||||||||||||||||
| .sum::<u32>() | ||||||||||||||||||||
|
|
@@ -7073,6 +7074,7 @@ fn count_yields(expression: &Expr) -> u32 { | |||||||||||||||||||
| .iter() | ||||||||||||||||||||
| .map(|argument| match argument { | ||||||||||||||||||||
| CallArgument::Expression(value) => count_yields(value), | ||||||||||||||||||||
| CallArgument::Spread(spread) => count_yields(&spread.argument), | ||||||||||||||||||||
| _ => 0, | ||||||||||||||||||||
| }) | ||||||||||||||||||||
| .sum::<u32>() | ||||||||||||||||||||
|
|
@@ -7301,7 +7303,10 @@ fn machine_state_name(skip: &std::collections::HashSet<String>, temps: &[String] | |||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| fn call_argument_suspends(argument: &CallArgument) -> bool { | ||||||||||||||||||||
| matches!(argument, CallArgument::Expression(value) if contains_yield(value)) | ||||||||||||||||||||
| match argument { | ||||||||||||||||||||
| CallArgument::Expression(value) => contains_yield(value), | ||||||||||||||||||||
| CallArgument::Spread(spread) => contains_yield(&spread.argument), | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+7306
to
+7309
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (bug_risk): The new match is non-exhaustive because Suggested fix: Handle
Suggested change
|
||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| /// Whether an assignment target subtree still holds an await, so the | ||||||||||||||||||||
|
|
@@ -7340,6 +7345,7 @@ fn contains_await(expression: &Expr) -> bool { | |||||||||||||||||||
| contains_await(&call.callee) | ||||||||||||||||||||
| || call.arguments.iter().any(|argument| match argument { | ||||||||||||||||||||
| CallArgument::Expression(value) => contains_await(value), | ||||||||||||||||||||
| CallArgument::Spread(spread) => contains_await(&spread.argument), | ||||||||||||||||||||
| _ => false, | ||||||||||||||||||||
| }) | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
@@ -7348,6 +7354,7 @@ fn contains_await(expression: &Expr) -> bool { | |||||||||||||||||||
| contains_await(&new.callee) | ||||||||||||||||||||
| || new.arguments.iter().any(|argument| match argument { | ||||||||||||||||||||
| CallArgument::Expression(value) => contains_await(value), | ||||||||||||||||||||
| CallArgument::Spread(spread) => contains_await(&spread.argument), | ||||||||||||||||||||
| _ => false, | ||||||||||||||||||||
| }) | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
@@ -7388,6 +7395,10 @@ fn contains_await(expression: &Expr) -> bool { | |||||||||||||||||||
| Expression::Parenthesized(inner) => contains_await(inner), | ||||||||||||||||||||
| Expression::As(cast) => contains_await(&cast.expression), | ||||||||||||||||||||
| Expression::NonNull(non_null) => contains_await(&non_null.expression), | ||||||||||||||||||||
| Expression::Import(import) => { | ||||||||||||||||||||
| contains_await(&import.source) | ||||||||||||||||||||
| || import.options.as_deref().is_some_and(contains_await) | ||||||||||||||||||||
| } | ||||||||||||||||||||
| _ => true, | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (broader_impact): Spread arguments are now counted as containing yields, but
contains_yieldstill ignoresCallArgument::Spread; the earlyevalguard therefore treats calls such asf(...(yield value))as non-suspending and leaves the yield inside the emitted call instead of lowering it.Triggers: When a generator contains a yield expression inside a call or constructor spread argument.
Suggested fix: Traverse
CallArgument::Spread(spread).argumentincontains_yieldas well, keeping the suspension predicates consistent.