Skip to content

Fix: [for cherry-picking] Updated suspension walkers to inspect call/ne - #200

Closed
qodo-code-review[bot] wants to merge 2 commits into
diamond/walker-lockstep-pinsfrom
fix/remediation-5f6a39a1-8c9c6d
Closed

Fix: [for cherry-picking] Updated suspension walkers to inspect call/ne#200
qodo-code-review[bot] wants to merge 2 commits into
diamond/walker-lockstep-pinsfrom
fix/remediation-5f6a39a1-8c9c6d

Conversation

@qodo-code-review

@qodo-code-review qodo-code-review Bot commented Sep 4, 2026

Copy link
Copy Markdown

Fixed Findings

  • Traverse call and new spread arguments
  • Link regression evidence to the G3 root gate
  • Traverse dynamic import awaits

Automated fix from agentic review of #199

Qodo Logo

Summary by Sourcery

Extend suspension walkers to cover spread arguments and dynamic import expressions while clarifying regression-gate evidence requirements.

Bug Fixes:

  • Ensure suspension analysis detects yields and awaits inside call and constructor spread arguments.
  • Include awaits in dynamic import sources and options during suspension analysis.

Documentation:

  • Clarify that regression results require receipt-backed linkage to the G3 compiler root gate for completion.

Summary by cubic

Fixes suspension walkers so yields in spread arguments and awaits in dynamic imports are now detected during suspension analysis. Previously, these constructs were skipped, potentially missing suspension points in generated generators.

Bug Fixes

  • count_yields, call_argument_suspends, and contains_await now inspect CallArgument::Spread arguments.
  • contains_await now checks dynamic import sources and options via Expression::Import.

Documentation

  • Clarifies that regression results require receipt-backed linkage to the G3 compiler root gate for completion.

Written for commit 5bbb1c6. Summary will update on new commits.

Review in cubic

@sourcery-ai

sourcery-ai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates generator suspension walkers to recognize yields and awaits nested in call/new spread arguments and dynamic import expressions, while clarifying the required G3 root-gate linkage for regression evidence.

Flow diagram for suspension analysis of nested expressions

flowchart TD
    Expr[Expression] --> Kind{Expression kind}
    Kind --> Call[Call or new expression]
    Call --> Args[Inspect arguments]
    Args --> Spread[Spread argument]
    Spread --> Nested[count_yields or contains_await]
    Kind --> Import[Dynamic import expression]
    Import --> Source[Inspect import source]
    Import --> Options[Inspect import options]
    Source --> Await[contains_await]
    Options --> Await
Loading

File-Level Changes

Change Details Files
Extend suspension analysis to traverse spread arguments and dynamic import subexpressions.
  • Count yields inside spread arguments for calls and constructors.
  • Detect awaits in spread arguments for calls and constructors.
  • Treat spread arguments as suspension-bearing in call analysis.
  • Inspect dynamic import sources and optional import options for awaits.
crates/bamts-compiler/src/emitter/transforms.rs
Clarify that regression test results must be linked to the compiler root-gate evidence.
  • Document the required receipt-backed G3 linkage beyond corpus test results.
docs/solutions/logic-errors/es5-generator-suspension-walker-divergence.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery assessment

Approved.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="crates/bamts-compiler/src/emitter/transforms.rs" line_range="7306-7309" />
<code_context>

 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),
+    }
 }

</code_context>
<issue_to_address>
**issue (bug_risk):** The new match is non-exhaustive because `CallArgument` also has the `Missing` variant, as handled by `rewrite_call_arguments`; the crate fails to compile with a non-exhaustive-pattern error.

**Suggested fix:** Handle `CallArgument::Missing(_)` as non-suspending, or retain a wildcard arm.

```suggestion
    match argument {
        CallArgument::Expression(value) => contains_yield(value),
        CallArgument::Spread(spread) => contains_yield(&spread.argument),
        CallArgument::Missing(_) => false,
    }
```
</issue_to_address>

### Comment 2
<location path="crates/bamts-compiler/src/emitter/transforms.rs" line_range="7058" />
<code_context>
                     .iter()
                     .map(|argument| match argument {
                         CallArgument::Expression(value) => count_yields(value),
+                          CallArgument::Spread(spread) => count_yields(&spread.argument),
                         _ => 0,
                     })
</code_context>
<issue_to_address>
**issue (broader_impact):** Spread arguments are now counted as containing yields, but `contains_yield` still ignores `CallArgument::Spread`; the early `eval` guard therefore treats calls such as `f(...(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).argument` in `contains_yield` as well, keeping the suspension predicates consistent.
</issue_to_address>

Sourcery assessment

Approval pending. 2 findings to address first.

Blocking findings: crates/bamts-compiler/src/emitter/transforms.rs:7309, crates/bamts-compiler/src/emitter/transforms.rs:7058


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment on lines +7306 to +7309
match argument {
CallArgument::Expression(value) => contains_yield(value),
CallArgument::Spread(spread) => contains_yield(&spread.argument),
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): The new match is non-exhaustive because CallArgument also has the Missing variant, as handled by rewrite_call_arguments; the crate fails to compile with a non-exhaustive-pattern error.

Suggested fix: Handle CallArgument::Missing(_) as non-suspending, or retain a wildcard arm.

Suggested change
match argument {
CallArgument::Expression(value) => contains_yield(value),
CallArgument::Spread(spread) => contains_yield(&spread.argument),
}
match argument {
CallArgument::Expression(value) => contains_yield(value),
CallArgument::Spread(spread) => contains_yield(&spread.argument),
CallArgument::Missing(_) => false,
}

.iter()
.map(|argument| match argument {
CallArgument::Expression(value) => count_yields(value),
CallArgument::Spread(spread) => count_yields(&spread.argument),

Copy link
Copy Markdown

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_yield still ignores CallArgument::Spread; the early eval guard therefore treats calls such as f(...(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).argument in contains_yield as well, keeping the suspension predicates consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants