← board

Inc/Dec intrinsic rejects non-bare-symbol lvalue actuals

Reframe

Filed as "library var/out parameters accept general lvalue actuals", on the theory that passing rec.field / arr[i] / Self.field to a by-ref parameter was unsupported and Inc should become an RTL procedure to exercise it.

Investigation shows the broad premise is false: general var/out lvalue actuals already work for user routines. A procedure Adjust(var x: Integer) called with a local, a record field, an array element, an implicit-Self field, and an explicit Self.field all pass by reference and write back correctly (test /tmp/vo.pas, all five). So no RTL re-implementation of Inc is needed.

The real defect is narrow: the Inc/Dec intrinsic parsed only a bare identifier and then expected ), so Inc(rec.f), Inc(arr[i]), Inc(Self.field), Inc(p^.f) and the implicit-Self Inc(nodes) failed with Expected: ) / undefined. The ParseLValueAST call that consumes .field/[i]/^ selectors ran after the ) was already required.

Fix

fix(parser): Inc/Dec accept any assignable lvalue (e92ebd5). Parse the full target lvalue (selectors included) before the optional step and ), reusing the same ParseLValueAST machinery as assignment / by-ref params; drop the premature undefined error so an implicit-Self field resolves (a true unknown still errors). Inc/Dec stay compiler intrinsics — correct and sufficient; no System.Inc RTL surface required.

Acceptance — met

Log