← board

Untyped var / const / out parameters

Problem

FPC Move(const Source; var Dest; Count) / FillChar(var X; Count; Value) use untyped reference parameters — var/const/out with NO type. The caller passes the address of any-typed lvalue; the callee reaches the bytes via @X. PXX's parameter parser requires a type after every name (Expected ":"), so these can't be written as plain Pascal. This blocks Move/FillChar and any FPC source using untyped params.

Design

An untyped param is modelled as an existing by-reference (var) param with a placeholder type (tyPointer) plus an "untyped" marker:

  1. Parser (proc param loop, parser.inc ~9812): after the name list, if the next token is not :, treat it as untyped — require var/const/out (a typeless value param is meaningless), set tk := tyPointer, isByRef := True, and a per-param puntyped flag.
  2. Marker plumbing: puntyped[i] -> new global ProcParamUntyped[procIdx*16+i] (mirrors ProcParamIsConst).
  3. Overload match (MatchProcCall / MatchProcCallInUnit, symtab.inc): an untyped param matches ANY argument type (skip the type-compat check for that slot).
  4. Call site: the by-ref path already passes the argument's address (@arg), and @x on a var param already yields the referent address (verified) — so the callee body uses @Source / @Dest. No new marshalling.

Then (Track B, not this ticket)

With untyped params available, Move / FillChar become small lib/rtl functions over an overlap-safe byte move + a byte fill, auto-loaded so they resolve without uses (System surface). NOTE the existing internal PXXMemMove (builtinheap) is forward-only (memcpy) — Move must be overlap-safe (memmove): copy backward when dst > src and the ranges overlap. Only PXXMemZero exists; a general byte-fill is needed for FillChar.

Gate

make test (self-host byte-identical — the compiler's own source uses no untyped params, so it stays byte-identical) + make cross-bootstrap. Add a test exercising untyped var/const params (a hand-written mem-move/fill over @x), FPC objfpc oracle-matched.

Log