Skip to content

refactor: Tidy effect opcode handling#500

Merged
zharinov merged 5 commits into
masterfrom
refactor/drop-dead-clear-effect
Jun 21, 2026
Merged

refactor: Tidy effect opcode handling#500
zharinov merged 5 commits into
masterfrom
refactor/drop-dead-clear-effect

Conversation

@zharinov

@zharinov zharinov commented Jun 21, 2026

Copy link
Copy Markdown
Member

Summary

  • Remove the dead Clear effect and close the opcode gap it left, so effect opcodes stay contiguous.
  • Order struct effects open/insert/close to match arrays: Array{Open, Push, Close} = 1/2/3, Struct{Open, Set, Close} = 4/5/6.
  • Reference effect opcodes symbolically in the forged-module tests (via EffectKind + EFFECT_PAYLOAD_BITS) so a renumber or reorder flows through for free.

Why

Clear was a live runtime arm for an effect the compiler never emits. While tidying it, the opcode numbers turned out to be scattered as raw literals across the tests — one had already broken silently on the renumber. The numbers now live only in the EffectKind enum; everything else is symbolic.

Notes

Focused commits — delete Clear + close the gap, make the forged tests symbolic, the struct open/insert/close swap, then a docs tidy. The swap stays tiny because the tests are symbolic by then.

Nothing emits Clear, yet it stayed a live materializer/VM arm. Remove the EffectKind and RuntimeEffect variants and every decode/materialize/trace/format arm, plus the load-pass and compile-verify no-op cases.

The opcodes after it close the gap, so the effect opcode space stays contiguous: Null becomes 9, SuppressBegin 10, SuppressEnd 11.
@zharinov
zharinov force-pushed the refactor/drop-dead-clear-effect branch from fb45948 to ddee25f Compare June 21, 2026 16:26
zharinov added 2 commits June 21, 2026 13:48
The forged-module tests hard-coded effect opcodes as raw numbers (`op == 6`, `2u16 << 10`, "opcode 11" in comments). The renumber broke one silently: `forged_preamble_without_root_struct` wrote `10u16` meaning `Null`, but after the renumber opcode 10 is `SuppressBegin`, so it passed for the wrong reason.

Reference `EffectKind` and `EFFECT_PAYLOAD_BITS`/`EFFECT_PAYLOAD_MAX` instead, with an `effect_word` helper for the raw byte construction. A renumber or reorder of the opcodes now flows through the tests for free.
Struct effects were StructOpen(4), StructClose(5), Set(6), so the insert (Set) sat after the close — inconsistent with arrays, where Push sits between ArrayOpen and ArrayClose. Swap Set and StructClose so both composites read open / insert / close: Array{Open,Push,Close} = 1/2/3, Struct{Open,Set,Close} = 4/5/6.
@zharinov zharinov changed the title refactor: Delete dead Clear effect refactor: Tidy effect opcode handling Jun 21, 2026
zharinov added 2 commits June 21, 2026 13:56
"currently 12 defined", "(0-11)", and the `SuppressBegin (10)`/`SuppressEnd (11)` numbers duplicated the opcode table just above and rotted on every renumber. The table is the source of truth.
The enum-ordering comment restated what the variant values already show, and the `effect_word` doc restated its one-line body. Remove both.
@zharinov
zharinov enabled auto-merge (squash) June 21, 2026 17:10
@zharinov
zharinov merged commit 48202af into master Jun 21, 2026
4 checks passed
@zharinov
zharinov deleted the refactor/drop-dead-clear-effect branch June 21, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant