[GH-ISSUE #6] Support safe RETURN hooks for functions containing calls beneath references #2

Closed
opened 2026-11-02 15:32:18 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @sofia-gros on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon-mixins/issues/6

Use case
I would like to customize the item stack returned by a server-side block-pick handler while preserving the host’s original result construction. A RETURN hook could add block-specific data without replacing the entire operation.

Observed behavior
Tested revisions:

  • Horizon: b6c936f82b08798057161bdfa577e3aac53fb91e
  • horizon-mixins: cb1ad23022

A RETURN injection targeting horizon_client::game::block_items::Game<'_>::picked_stack fails during planning, even when its helper returns the original Option unchanged:

E_UNSUPPORTED_CONTROL_FLOW: calls beneath a reference may change temporary lifetimes

The target function contains an expression such as Some(&Tag::Compound(all)).

This appears consistent with the safety restrictions in the tested revision. I am requesting additional supported coverage, rather than reporting the rejection itself as a bug. I have not verified whether the restriction remains in newer revisions.

Alternative considered
A cancellable HEAD hook on the same function plans and applies on the tested revision. A HEAD-based implementation has subsequently been tested for LAN block picking. It replaces the result for intercepted blocks, however, rather than modifying the original result, so it must reproduce the relevant host behavior.

The earlier HEAD/macro restriction discussed in #1 and addressed by #2 is separate from this RETURN restriction.

Request
Could a narrowly scoped, safe RETURN transformation support this case? Alternatively, is there an existing supported approach for modifying the original result without duplicating its construction?

Any extension should preserve temporary lifetimes, evaluation order, borrowing, and control-flow semantics. I am not proposing that the existing safety checks simply be disabled.

Originally created by @sofia-gros on GitHub (Oct 30, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon-mixins/issues/6 **Use case** I would like to customize the item stack returned by a server-side block-pick handler while preserving the host’s original result construction. A RETURN hook could add block-specific data without replacing the entire operation. **Observed behavior** Tested revisions: - Horizon: b6c936f82b08798057161bdfa577e3aac53fb91e - horizon-mixins: cb1ad23022392d88f006cf94cbf6552a73f5df12 A RETURN injection targeting horizon_client::game::block_items::Game<'_>::picked_stack fails during planning, even when its helper returns the original Option<ItemStack> unchanged: E_UNSUPPORTED_CONTROL_FLOW: calls beneath a reference may change temporary lifetimes The [target function](https://github.com/horizon-rust/horizon/blob/b6c936f82b08798057161bdfa577e3aac53fb91e/crates/horizon-client/src/game/block_items.rs#L41) contains an expression such as Some(&Tag::Compound(all)). This appears consistent with the safety restrictions in the tested revision. I am requesting additional supported coverage, rather than reporting the rejection itself as a bug. I have not verified whether the restriction remains in newer revisions. **Alternative considered** A cancellable HEAD hook on the same function plans and applies on the tested revision. A HEAD-based implementation has subsequently been tested for LAN block picking. It replaces the result for intercepted blocks, however, rather than modifying the original result, so it must reproduce the relevant host behavior. The earlier HEAD/macro restriction discussed in #1 and addressed by #2 is separate from this RETURN restriction. **Request** Could a narrowly scoped, safe RETURN transformation support this case? Alternatively, is there an existing supported approach for modifying the original result without duplicating its construction? Any extension should preserve temporary lifetimes, evaluation order, borrowing, and control-flow semantics. I am not proposing that the existing safety checks simply be disabled.
Author
Owner

@levzzz5154 commented on GitHub (Oct 30, 2026):

🤖 Agent: RETURN hooks on functions shaped like picked_stack are supported as of 5140cdf (#9). References to calls (such as Some(&Tag::Compound(all))) and plain closures are now allowed anywhere except inside the returned values themselves; the rest of the body is left as written, so temporaries keep their lifetimes. The $value binding type has to be spelled exactly as the target spells its result: Option<ItemStack>, otherwise planning fails with E_INVALID_BINDING. A launcher build uses this once a bundle names this horizon-mixins revision.

<!-- gh-comment-id:6523847090 --> @levzzz5154 commented on GitHub (Oct 30, 2026): 🤖 Agent: RETURN hooks on functions shaped like `picked_stack` are supported as of 5140cdf (#9). References to calls (such as `Some(&Tag::Compound(all))`) and plain closures are now allowed anywhere except inside the returned values themselves; the rest of the body is left as written, so temporaries keep their lifetimes. The `$value` binding type has to be spelled exactly as the target spells its result: `Option<ItemStack>`, otherwise planning fails with `E_INVALID_BINDING`. A launcher build uses this once a bundle names this horizon-mixins revision.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon-mixins#2
No description provided.