mirror of
https://github.com/horizon-rust/horizon-mixins.git
synced 2026-12-03 19:34:02 +07:00
[PR #14] [MERGED] feat(plan): modify a variable in functions with closures and ? elsewhere #18
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
horizon-rust/horizon-mixins#18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/horizon-rust/horizon-mixins/pull/14
Author: @reservedbytes
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @levzzz5154
Base:
main← Head:feat/modify-variable-closures📝 Commits (2)
4ad05bafeat(plan): modify a variable in functions with closures and ? elsewhere2145b5cMerge remote-tracking branch 'origin/main' into p14📊 Changes
7 files changed (+202 additions, -6 deletions)
View changed files
📝
README.md(+2 -1)➕
crates/horizon-mixins-cli/tests/cases/variables.rs(+152 -0)📝
crates/horizon-mixins-cli/tests/integration.rs(+3 -0)📝
crates/horizon-mixins-core/src/plan.rs(+31 -2)📝
crates/horizon-mixins-core/src/scopes.rs(+3 -2)📝
docs/mixin-api.md(+3 -1)📝
docs/scopes-and-bridges.md(+8 -0)📄 Description
What and why
#9 let RETURN plan in functions with closures and references to calls outside the values it moves, MODIFY_VARIABLE still refused the whole function
Horizon's
Mob::damage_withhas a closure (.then(|| golem::crackiness(self))), so a MODIFY_VARIABLE on itsamountfails withE_UNSUPPORTED_CONTROL_FLOWeven though the hook only touches one read or one storeMODIFY_VARIABLE now works like RETURN after #9: only the value it replaces is checked (a closure, a
?or a call beneath a reference there stays refused), and the rest of the body is left alone,?included since it isn't an exit a variable hook could missA closure's own locals already stay out of ordinals (#9), and a read or write of the variable inside a closure still counts toward
requirebut selecting it isE_UNSUPPORTED_LOCAL, since no hook runs thereOther hooks that rewrite inside the body keep the whole-body check
On Horizon
main(70436b6) a MODIFY_VARIABLE onMob::damage_with'samount(the parameter at LOAD, and the local at STORE) went fromE_UNSUPPORTED_CONTROL_FLOWto planning, and the staged game compilesChecks
cargo fmt --all --checkcargo clippy --workspace --all-targets --locked -- -D warningscargo test --workspace --locked(96 passed, new testsvariable_hooks_leave_closures_question_marks_and_referenced_calls_outside_the_value_alone, which fails without the fix, andvariable_hooks_still_refuse_closures_question_marks_and_referenced_calls_in_the_value)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.