Skip to content

feat(ts): lower bool's then and then_some from core's MIR - #180

Merged
kixelated merged 4 commits into
mainfrom
quest/m3/ts-bool-core
Oct 28, 2026
Merged

kixelated merged 4 commits into
mainfrom
quest/m3/ts-bool-core

Conversation

@kixelated

@kixelated kixelated commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

rt.boolThen was the last runtime combinator that took a closure dropper, restating core's drops by hand. rt.thenSome did the same for its value.

Approach

library::from_mir takes bool's inherent methods too, so then and then_some lower from core's MIR into core/bool.ts, as #129 did Option's and Result's. Their mappings, discards and none_last entries, and both runtime functions are deleted.

rt.once stays: OnceCell::get_or_init still wraps a closure that Fn calls in it. Its only test was bool::then with a bound closure, so drops/once.rs gains one called and one uncalled bound closure through get_or_init. A mutation of rt.once that skips the drop after the call fails the task differential (243 differences).

Tests: just check and just test pass. Drops are checked against native Rust by the existing then/then_some cases in drops.rs, drops/closures.rs, nested.rs, shapes.rs, and iters.rs, including Option<Option<_>> and () payloads.

Bundle size: the codec's bench and Decoder bundles are unchanged, since neither reaches bool::then. Only the codec harness calls then_some, which is now thenSome$bool_u64. moq-net's translation (just ts moq) never calls either and still type-checks.

The merge from main also regenerates lang's dyns.ts snapshot, which #176 and #177 left stale on main.

Impact

  • Translator output: bool::then and then_some calls become calls of then$bool_… and thenSome$bool_… from core/bool.ts.
  • Runtime: rt.boolThen and rt.thenSome are removed. MIGRATE.md has an entry.
  • Every inherent bool method in core now lowers from MIR, unstable ok_or/ok_or_else included, under the same &mut, unsafe, and wrapping-arithmetic refusals.

Alternatives

  • Allowlisting only then and then_some. Rejected: Option and Result take their whole impl, and std_refused already guards each body.

Follow-ups

  • None needed. rt.once has one consumer left, get_or_init, which lowers through the runtime because its body writes through UnsafeCell.

(written by Claude Opus 5.5)

🤖 Generated with Claude Code

kixelated and others added 3 commits October 28, 2026 07:24
Quest-Claim: 050e4d073300253d
The runtime drops rt.boolThen and rt.thenSome. rt.once stays for
get_or_init, which a new once case covers against native Rust.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Regenerates lang's dyns.ts snapshot, which #176 and #177 left stale on main.
@kixelated kixelated changed the title bool's combinators from core's MIR feat(ts): lower bool's then and then_some from core's MIR Oct 28, 2026
@kixelated
kixelated marked this pull request as ready for review October 28, 2026 14:38
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T16:59:17.239538Z ab172e0 Manual request
🔒 Security Review ✅ Completed 2026-10-28T17:01:14.090868Z ab172e0 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 1bacb03

No actionable bugs found. Lowering bool combinators through the existing core-MIR path is a sensible simplification over duplicating ownership/drop behavior in runtime helpers. Inspected the generated eager/lazy branches, captured-closure disposal (including Fn-to-FnOnce), nested Option/unit sentinels, migration notes, and the replacement OnceCell coverage for rt.once. Keeping that wrapper for its remaining consumer is justified.

Verification: static code and fixture inspection only. I did not run tests, translations, or bundle-size measurements; the reported results in the PR description are not independently verified.

# Conflicts:
#	ts/fixtures/reject/census.md
#	ts/fixtures/task/expected/drops/closures.ts
@kixelated

Copy link
Copy Markdown
Collaborator Author

@codex review

(written by Claude Opus 5.5)

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: ab172e0dd5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: ab172e0dd5

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@kixelated

Copy link
Copy Markdown
Collaborator Author

Landing at ab172e0, the head Codex reviewed with no findings; CI passed. bool::then and then_some lower from core's MIR, rt.boolThen and rt.thenSome are removed, and rt.once stays for get_or_init with new differential coverage. No open decisions.

(written by Claude Opus 5.5)

@kixelated
kixelated merged commit 59ae88e into main Oct 28, 2026
1 check passed
@kixelated
kixelated deleted the quest/m3/ts-bool-core branch October 28, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant