Skip to content

Clone a chain index before the getter consumes it - #1140

Merged
ImTheSquid merged 2 commits into
mainfrom
jack/grain-vm-index-writeback
Aug 20, 2026
Merged

Clone a chain index before the getter consumes it#1140
ImTheSquid merged 2 commits into
mainfrom
jack/grain-vm-index-writeback

Conversation

@ImTheSquid

Copy link
Copy Markdown
Collaborator

index_by_reference cloned the index for the write-back setter after calling get_indexed_mut, which binds a native's by-value parameter by take. The setter was called with (), found nothing, and call_indexer_set swallowed the error. The write was dropped silently. Rhai clones before the same call (eval/chaining.rs:706). Only the paths that can write pay for it.

`index_by_reference` cloned the index for the write-back setter after
calling `get_indexed_mut`, which binds a native's by-value parameter by
`take` — so the setter was called with `()`, found nothing, and
`call_indexer_set` swallowed the error. The write was dropped silently.

Rhai clones before the same call (`eval/chaining.rs:706`). Only the
paths that can write pay for it.
@ImTheSquid
ImTheSquid requested a review from schungx August 19, 2026 22:01
@schungx schungx added regression vm Issues related to the Rhai Grain bytecodes compiler and VM. labels Aug 20, 2026

@schungx schungx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

EDIT: See below for another change to fix a related bug.

@schungx schungx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix another big in one go.

Comment thread src/grain/vm/mod.rs Outdated
@ImTheSquid
ImTheSquid merged commit 58be46f into main Aug 20, 2026
51 checks passed
@ImTheSquid
ImTheSquid deleted the jack/grain-vm-index-writeback branch August 20, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

regression vm Issues related to the Rhai Grain bytecodes compiler and VM.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants