FA-90165 / Bytecode virtual machines / Member archive
LEB128 immediates: decoding stops on continuation bytes · case 05
Multi-byte immediates are cut after their first byte and single-byte ones swallow the next operand.
Case contract
Decode consecutive LEB128 immediates of kinds u32, s32, u64, s64 from a byte list: 7 payload bits per byte, least significant group first, bit 0x80 means another byte follows; at most ceil(bits/7) bytes (5 for 32-bit, 10 for 64-bit). Signed kinds sign-extend from bit 0x40 of the final byte; u32/s32 values outside their range are errors. Return decoded values followed by the first error, if any: ["unexpected-end", pos], ["too-long", pos] or ["out-of-range", pos].
Why this case matters
Compact bytecode formats encode immediates with LEB128; decoding errors silently change operands.
One recorded failure
Sample boundary fixtureThis sample comes from the broken implementation of a controlled reproducer.
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: mixed immediates | [13, -89, ["unexpected-end", 5]] | [5005, -385, -1] | Failed |
MEMBER ARCHIVE
The complete case is available to members.
This record includes three runnable implementations, regression fixtures, execution results, and source hashes.
Member access is invitation-based. Sign in with your invited account to inspect the sources.
Sign in to the archive ↗