← board

Member access on a function-call result (f(args).field)

Symptom

examples/adventure/engine.pas:446 cannot compile:

WriteLn(Col('  The way ' + DirName(d) + ' is sealed. You lack ' +
            CatalogItem(key).Name + '.', YEL));
pascal26:446: error: expected comma or close parenthesis

The offending sub-expression is CatalogItem(key).Name — a .field (or method) access applied directly to the result of a function call, where the function returns a class/record.

Minimal repro:

program callresult_member;
type TItem = class Name: AnsiString; end;
function MakeItem: TItem;
begin Result := TItem.Create; Result.Name := 'sword'; end;
begin
  Writeln(MakeItem.Name);   { or MakeItem().Name — error: expected comma or ')' }
end.

Direction

The expression/postfix parser handles ident.field, ident[i].field, etc., but does not continue parsing .field / [i] / ^ selectors after a function-call primary f(args). After building the AN_CALL node for the call, the selector loop should run on it (the call result's record type is available via ProcRetRecId, already used by ResolveNodeRec for AN_CALL). Apply in both the factor/expression path and ParseLValueAST so f().field := x works too.

Acceptance

Log