Skip to content

Restore Amb bracket state when first-of exits - #19

Merged
ademar merged 1 commit into
masterfrom
cursor/critical-bug-management-b191
Jul 26, 2026
Merged

Restore Amb bracket state when first-of exits#19
ademar merged 1 commit into
masterfrom
cursor/critical-bug-management-b191

Conversation

@cursor

@cursor cursor Bot commented Jul 26, 2026

Copy link
Copy Markdown

Bug

first-of escaped through call/cc before active amb-bracket and amb-bracket-range continuations could run their leave! callbacks. A successful first-result search therefore left caller-owned mutable state marked.

Fix

Add an internal escape-cleanup chain. Bracketed choices register their leave! callback while their continuation is active, and first-of unwinds that chain before returning its first solution.

Validation

  • Added a regression covering nested list/range brackets and verifying state returns to zero.
  • dotnet run --project IronKernel -- test lib/IronKernel.Amb/IronKernel.Amb.ikproj (20 checks passed)
  • dotnet test IronKernel.sln -c Release (225 passed)
  • Interactive REPL reproduction now returns the first solution (3) with bracket state restored to 0.
Open in Web View Automation 

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Low Risk
Scoped fix to IronKernel.Amb search semantics with a regression test; no auth, I/O, or host integration changes.

Overview
Fixes a bug where first-of returned the first solution via call/cc without running active amb-bracket / amb-bracket-range leave! hooks, leaving caller mutable state inconsistent.

Introduces an escape cleanup chain (parallel to sink) and with-bracket, which registers each bracket’s teardown while its continuation runs. first-of routes the first emitted solution through that chain before returning, and amb-bracket / amb-bracket-range delegate bracketing to with-bracket instead of inline enter/leave around k.

Adds a regression test that nested list/range brackets under first-of restore test counter state to zero after the first result (3).

Reviewed by Cursor Bugbot for commit acdb952. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-authored-by: Ademar Gonzalez <ademar@users.noreply.github.com>
@ademar
ademar marked this pull request as ready for review July 26, 2026 13:24
@cursor

cursor Bot commented Jul 26, 2026

Copy link
Copy Markdown
Author

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_8145d4ef-b092-4941-8afe-abc17b6f7649)

@ademar
ademar merged commit a418fca into master Jul 26, 2026
2 checks passed
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.

2 participants