Repository navigation
store the value of a captured variable, not its box - #171
Open
singhharsh1708 wants to merge 1 commit into
Open
singhharsh1708 wants to merge 1 commit into
singhharsh1708 wants to merge 1 commit into
Conversation
A variable that an inner function captures and reassigns is a `Core.Box` in the body that slot types are inferred from, so the state machine field was typed `Core.Box` while the transformed body assigns the value itself, and the assignment failed to convert. The field is the storage, so the box is not needed. Infer such a slot as `Any` instead, in the declared bound and in the type the generated constructor instantiates. Fixes JuliaDynamics#134. The two `@test_broken` for it now pass, and the closure example from the issue is covered as well.
singhharsh1708
force-pushed
the
unbox-captured-slots
branch
from
September 13, 2026 05:56
6a6193b to
456c7dd
Compare
Benchmark Results (Julia v1)Time benchmarks
Memory benchmarks
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #134.
The issue has it the other way round: the slot is not given the un-boxed type, it is given
Core.Box. A variable an inner function captures and reassigns is aCore.Boxin the bodyget_slotsinfers from, while the transformed body assigns the value itself, so the conversion fails. The state machine field is the storage, so the box is redundant, and such a slot is nowAny. Both the declared bound and the type the generated constructor instantiates need it, since they are computed separately.Both
@test_brokenpass now, and the closure example from the issue is covered too.test_maingoes from 44 passing and 2 broken to 47 passing, on 1.10, 1.11 and 1.12.Numbered 1.0.9 now that 1.0.8 shipped with #174; #168 also claims 1.0.9, so whichever lands second renumbers.