← board

class helper for is not parsed

Repro

program h;
type
  TBox = class
    Value: Integer;
  end;
  TBoxHelper = class helper for TBox
    function Doubled: Integer;
  end;
function TBoxHelper.Doubled: Integer; begin Result := Value * 2; end;
var b: TBox;
begin
  b := TBox.Create; b.Value := 21; writeln(b.Doubled); b.Free;
end.

FPC (-Mobjfpc) prints 42. pxx: error: unexpected token.

The semantics, if it is implemented

The probe pins the two that are easy to get wrong:

Only one helper is active for a given type at a point in the source (the last one in scope wins); the probe deliberately does not test that yet.

Scope note

Related but distinct, and not covered here: type helper for Integer (record / type helpers), which FPC gates behind {$modeswitch typehelpers}. Worth a separate ticket — the parse work overlaps, the binding rules do not.

Gate

Track P: make test + self-host fixedpoint (byte-identical). Note the Track P catch — the Pascal frontend lives in the shared lexer.inc/parser.inc, so this must not be edited concurrently with Track A.