writeonce/docs/examples/operators
shoney.arickathil ed6bfeea3d feat: iteration 36 task 5 — operators sample, docs closeout
- docs/examples/operators: manual-test workload (ok/FAIL lines per
  expression; trap mode proves WO_T_SHIFT); NO test fixtures by
  developer directive — acceptance is the manual pass
- 00-wob-format.md: v6 section (opcodes 42-46, T_SHIFT, header v6)
- CODE-LOGIC.md both sides: precedence-into-existing-rungs, Lua not,
  rewind-and-reparse compound assigns, trap-not-mask, 63-bit hex limit
- story 36 refine -> in-progress with landing blockquote; board updated
- gates: woc-test 543/0, wovm-test ASan, oop-accept ALL MET,
  deps-accept 8/0, web-app 26/0

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-22 21:42:08 +02:00
..
main.wo feat: iteration 36 task 5 — operators sample, docs closeout 2026-08-22 21:42:08 +02:00
README.md feat: iteration 36 task 5 — operators sample, docs closeout 2026-08-22 21:42:08 +02:00
wo.toml feat: iteration 36 task 5 — operators sample, docs closeout 2026-08-22 21:42:08 +02:00

operators — iteration 36's manual-test workload

Exercises everything iteration 36 added to the language: boolean not, the five Int bitwise operators (& | ^ << >>), hex/binary/ underscore integer literals, and the five compound assigns (+= -= *= /= %=).

Run it

woc .            # from this directory
./target/operators

Every line prints ok <label> = <value> — each label states the exact expression and the expected result, so a manual test is reading the lines and spotting any FAIL. The sections, in order:

  1. Literals — 0xFF, 0b1010_1010, 1_000_000 against their decimal twins.
  2. The five operators — including -16 >> 2 = -4 (>> is ARITHMETIC: the sign bit extends, the story's settled decision 1) and complement spelled -1 ^ x (no ~ in this language).
  3. Precedence pins — Go's C-trap fix: &/<</>> bind with *, |/^ bind with +, all above comparison, so x & mask == 0 groups the AND first and 1 << 4 + 1 is 17, not 32.
  4. not — a word like and/or, Lua's unary placement: not a == b groups (not a) == b.
  5. Compound assigns — one value threaded through all five.
  6. The consumer proof — HMAC's ipad/opad step (story 34's blocker): byte_at(key, i) ^ 0x36 / ^ 0x5C in pure .wo.

The trap

./target/operators trap

must die with trap 12 in shift_by ...: shift count out of range 0..63 (exit 1). A shift count outside 0..63 is a RUN-TIME trap only when the count is a variable — a literal out-of-range count never compiles (WO-E223, try changing 1 << 6 to 1 << 64).