← board

Val rejects the radix prefixes, and its code argument is not optional

Measured (before)

Val('$ff', v, c)     fpc 255 / 0     pxx 0 / 1
Val('xFF', v, c)     fpc 255 / 0     pxx 0 / 1
Val('0xFF', v, c)    fpc 255 / 0     pxx 0 / 2
Val('&17', v, c)     fpc  15 / 0     pxx 0 / 1
Val('%1011', v, c)   fpc  11 / 0     pxx 0 / 1
Val('7', i)          fpc 7           pxx "Expected: ,"

The silent half is the dangerous one: a caller that ignores code — which is most of them, and is exactly why the two-argument form exists — read a 0.

Fix

The failure POSITIONS are part of the contract and are asserted too: a bare prefix with no digits stops one past itself ('$' -> code 2), and '$1g' -> code 3.

Result

test/test_val_radix_and_optional_code.pas — 19 conversion rows plus the four optional-code shapes (int, float, QWord, and a failed one) — prints total ok 23 / 23 under both FPC 3.2.2 and pxx.

Gate

make compiler/pascal26 + the test under both compilers + tools/gate.sh quick — GREEN. A compiler/builtin change, so make stabilize-fast && make pin follows.

Log