Skip to content

fix(ts): substitute a census's type parameters into a body once - #263

Merged
kixelated merged 5 commits into
mainfrom
quest/m2/ts-async
Oct 30, 2026
Merged

kixelated merged 5 commits into
mainfrom
quest/m2/ts-async

Conversation

@kixelated

@kixelated kixelated commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

moq-net's census refused kio::Waiter::poll_future::<()>, which "names <() as Future>::Output, which does not normalize". The quest asked where polymorphic lowering makes the ().

Each MIR body is already instantiated with its instance's arguments (instance_mir), but Body::call_def, fn_value, std_places, and the &mut pointee check substituted a call's generic arguments again with Body.args. A translation has no parameters left, so the second pass did nothing. A census that lowers a generic function over its own type parameters keeps the root's parameters in every body it reaches, though. In moq-net, ietf::session::run_namespaces<F, O> reaches the closure in namespace_request's async body, whose poll_future::<O> names the root's O as #1. Substituting again against the coroutine's own arguments made #1 the coroutine's kind type, ().

Approach

Delete Body.args and Body::subst: a body's values are instantiated once, where its MIR is. fixtures/reject gets a generic async fn awaiting another whose closure names the outer function's second type parameter. Before the fix, its census refused poll_pinned::<()>. Now it refuses nothing.

Census at the pinned moq revision:

Census Before After
model 497 497
moq-net 1572 1571 (and 12086 to 12077 instances, the bogus () ones)
kio 153 153

The model's census refuses no async code. The quest is rewritten to what remains.

Impact

  • None to the translator's output: a translation had no parameters for the second substitution to change. A census no longer counts refusals of instances that substitution made up.

Alternatives

  • Substituting only the parameters a body's own instance declares. That still double-substitutes, so it was dropped.

Follow-ups

The quest keeps:

  • kio's Tasks: translated, it refuses a waker's identity (Waker::data and Waker::vtable compared as an Option<(*const (), *const RawWakerVTable)> in Polling, 10 of kio's refusals). Translating it means giving rt.Waker an identity, which every caller's own waker would then implement, so the shape is the maintainer's call.
  • rt.spawn's shape for callers and cancelling a spawned task, also runtime API.
  • Async closures, written only by moq-net's tests.

Review

  • Codex, gpt-6.1-sol, medium effort (quest review), round 3 on head 4ac681273cec010ec999bc327fb80fcb3a5c2ab9: no findings. Rounds 1 (700aa365) and 2 (417a3fc5) also had no findings. Rounds 2 and 3 cover the origin/main merges: fixtures/reject/census.md was regenerated and the two blocks appended to fixtures/reject/src/lib.rs were kept, main's first. The quest's mention of Vec::drain went with the slice-gaps quest, since #259 landed it.
  • Choices made without asking: the fixture case lives in fixtures/reject's census, the only census of a rootless crate.

Merge of main at 55a0457340f522fe201487581d7c7e50e99fb17e: git merged it without conflicts and just ci passed on this exact tree; it is a recorded skip, too trivial to review, on top of the clean review of 4ac68127.

(written by Claude Opus 5.5)

🤖 Generated with Claude Code

kixelated and others added 3 commits October 30, 2026 01:19
Quest-Claim: ed8b36641efe40d2
Each MIR body is instantiated with its instance's arguments already, but
Body substituted a call's generic arguments again. In a census lowered
over type parameters, a parameter of the root then took the argument at
its index in the body's own instance: a coroutine's kind, `()`. Drop
Body's arguments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	ts/fixtures/reject/census.md
@kixelated kixelated changed the title Async in the TypeScript translator fix(ts): substitute a census's type parameters into a body once Oct 30, 2026
@kixelated
kixelated marked this pull request as ready for review October 30, 2026 08:58
# Conflicts:
#	ts/fixtures/reject/census.md
#	ts/fixtures/reject/src/lib.rs

@kixelated kixelated left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Automated review by review (OpenAI)

Reviewed commit: 417a3fc5d2443b2b16bacec2af2e7aa61f492cd8.

No actionable bugs found in the inspected changes. Removing the second substitution is the simpler, correct boundary: ordinary and coroutine MIR are already instantiated, drop shims instantiate their MIR explicitly, and synthesized dynamic wrappers supply their method arguments directly. Retaining a second substitution with special-case filtering would preserve the underlying ambiguity about which function owns a type parameter.

The generic async census fixture targets the reported failure by carrying an outer function's second parameter through another future and its closure. Keeping the remaining waker-identity and task-cancellation API work separate is appropriate.

Verification limits: GitHub-only static review of substitution removal, affected call/function-value/place paths, MIR construction and the regression fixture, with an independent pass. No builds, tests or census runs were executed; the reported refusal-count improvements and unchanged generated output were not reproduced.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 17 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5d37de5d-c9d6-41ff-8512-1740fdc9d914
Commits

Reviewing files that changed from the base of the PR and between 417a3fc and 55a0457.

Files selected for processing: 9
  • quest/m2/ts-async.md
  • ts/fixtures/reject/census.md
  • ts/fixtures/reject/src/lib.rs
  • ts/src/lower/body.rs
  • ts/src/lower/dynamic.rs
  • ts/src/lower/mir/call.rs
  • ts/src/lower/mir/coroutine.rs
  • ts/src/lower/mir/glue.rs
  • ts/src/lower/mir/mod.rs

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 767cbf06-2ace-447d-bb5a-2b3af51e27ec
Commits

Reviewing files that changed from the base of the PR and between 5b6adaa and 417a3fc.

Files selected for processing: 9
  • quest/m2/ts-async.md
  • ts/fixtures/reject/census.md
  • ts/fixtures/reject/src/lib.rs
  • ts/src/lower/body.rs
  • ts/src/lower/dynamic.rs
  • ts/src/lower/mir/call.rs
  • ts/src/lower/mir/coroutine.rs
  • ts/src/lower/mir/glue.rs
  • ts/src/lower/mir/mod.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

Body no longer stores generic arguments, and its constructor no longer accepts them. Lowering methods and call sites now use the generic arguments passed directly to each operation. The reject fixture adds a generic async function and helpers, and its census totals increase. The async plan updates its notes about kio Tasks, Vec::drain, and Waiter::poll_future.

Priority: Pending latest changes

Merge Risk: Minimal · previous review 417a3

No actionable merge-blocking risk is identified. The change is mergeable subject to normal build and test checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: removing duplicate type-parameter substitution in a census body.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The pull request description directly explains the removal of duplicate generic-argument substitution, the affected MIR body APIs, the new regression fixture, census results, and follow-up scope. It i…
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 7 functions across 6 files. (2 skipped: 2 unsupported.)

Full details: Description check

Explanation

The pull request description directly explains the removal of duplicate generic-argument substitution, the affected MIR body APIs, the new regression fixture, census results, and follow-up scope. It is directly related to the changeset.

Finishing Touches
✨ Simplify code
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kixelated
kixelated merged commit e878a2e into main Oct 30, 2026
1 check passed
@kixelated
kixelated deleted the quest/m2/ts-async branch October 30, 2026 09:40
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.

1 participant