← board

Implicit textfile import misses method-local Text in units

Symptom

A simple program using the classic text-file surface now works:

program p;
var f: Text; s: AnsiString;
begin
  Assign(f, '/tmp/x'); Rewrite(f); WriteLn(f, 'alpha'); Close(f);
  Reset(f); ReadLn(f, s); Close(f); WriteLn(s);
end.

But examples/adventure still fails in the Engine unit at a method-local Text variable:

procedure TGame.SaveTo(const path: AnsiString);
var f: Text; it: TItem; sp: TSpell; m: TMonster;
begin
  Assign(f, path); Rewrite(f);
pascal26:563: error: undefined variable (Assign)

The same source gets past Assign if engine.pas explicitly imports textfile.

Root Cause

The implicit textfile loader scans tokens up front for a Text / TextFile identifier immediately preceded by :. That catches program-level declarations but misses at least this unit/method-local declaration shape before the unit's implementation body is parsed. As a result lib/rtl/textfile.pas is not loaded for the unit, so Assign and related routines remain unresolved.

Direction

Acceptance

Log