← board

General TypeName(expr) reinterpret cast (named record/class/pointer)

Motivation

PXX casts are still a fixed token allowlist in the factor parser (Integer/LongWord/Char/Boolean/String/Pointer/Ord/Chr/PChar). There is no general TypeName(expr) form for a user-named type — i.e. a reinterpret/checked cast to a named record, class, pointer-to-T, or type alias:

TFoo(p)^           { pointer reinterpret to a named record }
TDerived(baseObj)  { downcast a class reference (unchecked here; `as` is checked) }
PMyRec(addr)       { typed-pointer reinterpret }

Today these only work for the hardcoded builtins; a TypeName(expr) with a user type name falls through to "expected expression" or is misparsed.

Scope

Acceptance

Notes

Log

RESOLVED 2026-06-20 (Track A)

All the acceptance forms now work:

Verified: TRec(p)^.a/.b read and TRec(p)^.a := v write hit the right field offsets. make test + cross-bootstrap (i386/aarch64/arm32) byte-identical; test/test_record_typecast.pas added. (A bare value reinterpret TRec(x) without ^ — record value cast — is not part of this; the ^.field form covers the typed-pointer use the ticket and Track B reflection/binding code want.)

Resolved-in: 453bbc5 (finalizing commit)