uses <namespace> causes Access Violation

Issue #69 resolved
Anders Melander created an issue

Given a unit with the name test.a the compiler produces a name space symbol (TUnitSymbol.Main = nil) with the name test and a unit symbol (TUnitSymbol.Main <> nil) with the name test.a.

Compiling the following causes an Access Violation:

unit test.a;
begin
end.
program TestNameSpace;
uses
  test.a,
  test;
begin
end.

Cause

In TdwsCompiler.ReadUses the following block

         if z<0 then begin
            unitSymbol:=HandleExplicitDependency(names[x]);
            if unitSymbol<>nil then begin
               if unitSymbol.IsDeprecated then
                  WarnDeprecatedSymbol(posArray[x], unitSymbol.Main, unitSymbol.Main.DeprecatedMessage);
               z:=rt.IndexOfParent(unitSymbol.Table);
               if z>u then
                  rt.MoveParent(z, u);
            end;
         end;

calls unitSymbol.IsDeprecated:

function TUnitSymbol.IsDeprecated : Boolean;
begin
   Result:=(Main.DeprecatedMessage<>'');
end;

Since TUnitSymbol.Main is nil for a name space symbol this results in an AV.

Comments (1)

  1. Log in to comment