← board

bug: not on an integer is boolean-only on ESP (riscv32 / xtensa)

Symptom

not <integer> (bitwise complement) miscompiles on the ESP backends because their IR_NOT emits a boolean flip regardless of operand type:

The host fix (bug-not-on-int64-is-boolean) now types not <int-expr> as integer, so these ESP paths are reached by more programs; previously the boolean tag masked riscv32's defect for expressions (but not for not x).

Fix

Mirror the i386/aarch64 IR_NOT shape:

Verify

Bare-metal harness — tools/esp_run_bare.sh --chip esp32c3 (riscv32) and --chip esp32s3 (xtensa), UART vs x86-64 oracle (make test-esp-bare). Add an ESP variant of test/test_not_int64_expr.pas (Int64 + 32-bit ordinal not).

Acceptance

Resolution (2026-06-26, Track A — commit 40185664, pin v79)

riscv32 + xtensa IR_NOT now type-directed (mirror i386/aarch64): 64-bit -> complement both words; 32-bit ordinal-non-boolean -> full complement (riscv xori reg,-1, xtensa movi a8,-1); Boolean -> low-bit flip preserved. Verified by disassembly of test_not_int64_expr.pas — riscv emits xori reg,reg,-1 (a0 x11