Skip to content

Accept StringChunk where String is accepted: chunk setProp, script()/member(), arithmetic - #241

Open
TylerHamilton7 wants to merge 3 commits into
igorlira:mainfrom
TylerHamilton7:stringchunk-write-paths
Open

Accept StringChunk where String is accepted: chunk setProp, script()/member(), arithmetic#241
TylerHamilton7 wants to merge 3 commits into
igorlira:mainfrom
TylerHamilton7:stringchunk-write-paths

Conversation

@TylerHamilton7

Copy link
Copy Markdown
Contributor

Implements the three fixes from #237. One commit per lettered part, so they can be reviewed or dropped independently.

a) setProp on a string chunk. Dispatches SetProp on StringChunkHandlers to a set_prop_call that resolves the (chunkType, start[, end], value) range the way get_prop_inner parses its args.

It writes through set_contents, not set_value as I suggested in the issue text. set_value ignores its chunk_expr and replaces the entire source, so writing the modified chunk back through it truncates the field to just that chunk. I hit this in a local build before catching it — Junk Food Jack marks a collected item with member("roomN","screens").line[y].word[x] = "--", and with set_value the first pickup silently truncated that room's 19-line map to a single line. There is a comment at the call site.

b) script() / member() identifiers. StringChunk arms in MovieHandlers::script() and CastManager::find_member_ref_by_identifiers, mirroring the existing String arms.

c) Arithmetic operand. One arm in symbol_as_arithmetic_operand(), which all four ops already route through.

Repros: Junk Food Jack (Flashpoint 80cd4672-5b7c-46cb-bcb9-ea4adef35bdb) — collect any item (a); change room or die (b). Samurai Jack in Cavern Raid (36ec1007-0b46-4bb6-91bb-30ef37301189) — start a game (c).

Verified: cargo check --target wasm32-unknown-unknown is clean on this branch against main. On a wasm-pack build of main with this plus my two companion PRs applied, Junk Food Jack collects items, changes rooms and re-enters previously-visited rooms with their maps intact.

Fixes #237

🤖 Generated with Claude Code

TylerHamilton7 and others added 3 commits August 27, 2026 18:36
Director MX chunk assignment (str.char[i] = x) compiles to objCall
setProp on a chunk-typed receiver. StringChunkHandlers::call had no
SetProp arm and fell through with "No handler setProp for string chunk
datum".

Dispatches SetProp to a set_prop_call that resolves the inner range the
way get_prop_inner parses its args, then writes through set_contents.
Note set_value is not usable here: it ignores the chunk expression and
replaces the entire source, which truncates the field to the chunk being
written.

Refs igorlira#237

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
script(str.item[1]) raised "Invalid identifier for script" and
member(str.item[k]) raised "Member number or name type invalid: string
chunk", because both matched Datum::String explicitly and the fallback
coerced to int. Adds StringChunk arms mirroring the String ones.

Refs igorlira#237

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
add/subtract/multiply/divide have (String, Int|Float) arms for Director's
numeric-string coercion but no StringChunk arms, so a chunk operand
raised "Invalid operands". All four normalise through
symbol_as_arithmetic_operand(), so one arm there covers every op.

Refs igorlira#237

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StringChunk datum rejected where a String is accepted: chunk setProp, script()/member() identifiers, arithmetic operands

1 participant