Skip to content

Fix thunk stack growing#88

Merged
muukii merged 1 commit intomainfrom
muukii/patch-1767606022-from-main
Jan 5, 2026
Merged

Fix thunk stack growing#88
muukii merged 1 commit intomainfrom
muukii/patch-1767606022-from-main

Conversation

@muukii
Copy link
Copy Markdown
Contributor

@muukii muukii commented Jan 5, 2026

No description provided.

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Jan 5, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

@muukii muukii merged commit 47e4f53 into main Jan 5, 2026
1 of 3 checks passed
@muukii muukii deleted the muukii/patch-1767606022-from-main branch January 5, 2026 14:29
muukii added a commit that referenced this pull request Feb 3, 2026
## Summary

- Create generic `ClosureBox<R>` in `withTracking.swift` to eliminate
code duplication
- Fix thunk stack growing for `didChange` closure in
`withContinuousStateGraphTracking` by wrapping closures once at entry
point and passing them directly in recursive calls
- Remove duplicate private `ClosureBox` definitions from
`withGraphTrackingGroup.swift` and `withGraphTrackingMap.swift`
- Add `callAsFunction` support for cleaner invocation syntax

## Background

PR #88 fixed thunk stack growing issue for handler closures by wrapping
them in `ClosureBox`. However:
1. `ClosureBox` was duplicated in two files
2. `didChange` closure in `withContinuousStateGraphTracking` still had
the same thunk stack growing issue due to recursive wrapping/unwrapping
via `UnsafeSendable`

## Changes

| File | Changes |
|------|---------|
| `withTracking.swift` | Add generic `ClosureBox<R>` with
`callAsFunction`, add private `_withContinuousStateGraphTracking` |
| `withGraphTrackingGroup.swift` | Remove private `ClosureBox`, use
shared one |
| `withGraphTrackingMap.swift` | Remove private `ClosureBox`, use shared
one |

## Test plan

- [x] `swift build` passes
- [x] `swift test` passes (99 tests)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
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