Skip to content

feat: enforce tail-resumptive effect handlers (#564) - #1349

Merged
godofecht merged 5 commits into
mainfrom
cursor/effects-tail-resumptive-2586
Oct 6, 2026
Merged

godofecht merged 5 commits into
mainfrom
cursor/effects-tail-resumptive-2586

Conversation

@godofecht

@godofecht godofecht commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #564

Intent

Linked issue or roadmap item: #564 (algebraic effects are tail-resumptive only).

What changed, and why is this the smallest useful change?

This is a language-design question: abort, retry, and multi-shot need real continuation capture. The conservative 1.0 option is to keep tail-resumptive handlers, reject reserved resume / resume_multi in capability methods, and document Result/status and caller-loop encodings. Recorded in docs/project/Questions.md. Options 2/3 (abort-only, or general continuations) stay open for a later human decision.

Overlap check

  • I searched open pull requests and recent commits for overlapping work.
  • This does not duplicate another active implementation, or the relationship is explained below.

Overlap / dependency notes: No open PR implements abort/retry/multi-shot or the tail-resumptive rule. The RFC already accepted the limitation as documentation; this makes it a compiler-enforced 1.0 rule. Previous docs-only sessions were not merged.

Evidence

Baseline before this change: host-built flowc from the previous bootstrap (flowc: PASS). resume(x) in a capability method was an unbound/undefined call, not a dedicated diagnostic.

Targeted proof that exercises the changed behaviour:

  • Host compiler on compiler/fixtures/effects/resume_in_handler.flow and resume_multi_in_handler.flow: rejects with the tail-resumptive diagnostic.
  • compiler/fixtures/typecheck_rules/effect_resume.flow: same message.
  • ./flow test-lang tests/lang/test_effects_tail_resumptive.flow: two resumes in one handle block, status-code "abort" still returns to the call site, retry is a caller loop.

Why that proof would detect the old failure or regression: the reserved-form fixtures fail if the diagnostic is missing or the wording drifts. The language test fails if a handler return no longer resumes the call site or if a status-code "abort" skips the rest of the handle block.

Repository gate(s) run:

  • env -u FLOWC_IN -u FLOWC_OUT "$(./flow tool compiler/scripts/flowc_host.flow)" → flowc: PASS
  • ./compiler/scripts/bootstrap_from_c.sh --regen then --verify → ALL PASS bootstrap_from_c
  • ./flow test-lang → 267 passed, 0 failed
  • ./flow tool compiler/scripts/parity_effects.flow → 17 fixtures passed
  • ./flow tool compiler/scripts/typecheck_rules.flow → 126 passed, 0 failed
  • ./flow tool scripts/check_pkg_parity.flow → 133 pass, 1 fail (install-git-bad-tag extra git warning Could not find remote branch v404 to clone). Unrelated to effects; no package-manager files changed.

Generated/bootstrap state, if any: compiler/bootstrap/flowc_stage_a.c regenerated to the fixed point in a separate commit.

Risk

Compatibility, performance, security, lifetime, backend, or release implications:

New compile error only for resume / resume_multi inside a capability method. No ABI or codegen change. The C backend remains a thread-local handler pointer plus a direct call.

  • No unresolved language/API design decision is being implemented implicitly.
  • No unrelated generated artifacts or local state are included.
  • Docs changed when user-visible behaviour or syntax changed.
  • docs/project/Questions.md updated if this needs a language-design decision.

Compatibility

  • No user-visible compatibility change.
  • Compatibility change is documented in docs/project/CHANGELOG.md.

resume / resume_multi in a capability method become a type error.

Agent handoff

Cloud agent implementing #564. Not merging. Remaining continuation work (abort-only or general capture) is recorded in docs/project/Questions.md, not as an open gap of this PR.

Open in Web Open in Cursor 

cursoragent and others added 5 commits October 5, 2026 11:46
Keep algebraic-effect handlers as the conservative 1.0 model: a capability
method is an ordinary call that returns to the operation site. Reject the
reserved resume/resume_multi forms in handlers, document abort/retry as
caller-side encodings, and record the deferred continuation decision.

Co-authored-by: Abhishek Shivakumar <[email protected]>
flowc_stage_a.c now includes the #564 capability-method scan that rejects
resume/resume_multi. Verified with bootstrap_from_c.sh --verify.

Co-authored-by: Abhishek Shivakumar <[email protected]>
compiler/bootstrap: took main's, then bootstrap_from_c.sh --regen (fixed
point at gen2 on macOS; Linux x86-64 ELF rebuilt on the box). Checked-in
flowc_stage_a is Linux x86-64 like main's.

docs/project/CHANGELOG.md: kept main's entries and this branch's.

Also normalize em dashes in docs/language/cold-start.md and
compiler/src/main.flow so the pre-commit prose check passes (those came
from main).
Catch up after #1409. Only compiler/bootstrap/flowc_stage_a conflicted.
Took main's bootstrap and re-ran bootstrap_from_c.sh --regen (fixed point
at gen2; C unchanged vs prior tip). Checked-in flowc_stage_a is the Linux
x86-64 ELF.
parity_mlir --record on this branch. Updates the drifted
test_typecheck_overload_integration digest and records digests for
new fixtures this branch accepts.
@godofecht
godofecht merged commit cbe3e62 into main Oct 6, 2026
40 checks passed
godofecht added a commit that referenced this pull request Oct 6, 2026
Resolve bootstrap binary by taking main then regenerating.
godofecht added a commit that referenced this pull request Oct 6, 2026
Resolve bootstrap binary by taking main then regenerating.
godofecht added a commit that referenced this pull request Oct 6, 2026
godofecht added a commit that referenced this pull request Oct 7, 2026
…om closed PRs

Salvaged from closed pull requests whose code already landed:

- #1360 (region inference, code merged as #1390): region-inference.md,
  the tests/cgen region_inference and region_unproven goldens, and the
  spec, book, spans, lifetime-domains, README, spec-index, nav and
  CHANGELOG lines.
- #1368 (noalias, code merged as #1388): the spans.md paragraph on
  restrict .data temporaries and its noalias.md link.
- #1380 (tail-resumptive effects, code merged as #1349): the spec-index
  row for effects-continuations.md.

#1417 landed after #1360 and keeps an unproven forward copy as an
ordered element loop. The region_inference golden and the docs now say
that, in place of the memmove the closed branch expected. The golden
fails on the pre-#1417 compiler, which emitted memmove.
@godofecht
godofecht deleted the cursor/effects-tail-resumptive-2586 branch October 12, 2026 23:02
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.

Algebraic effects are tail-resumptive only: no abort, retry, or multi-shot continuations

2 participants