Page 1 of 1

Unexpected Compilation Error

Posted: Sun Aug 03, 2025 5:03 am
by gray
I have run into a puzzling compilation error, using the RP2350 command line compiler, latest version.

The following test case is distilled down from the real program by stepwise deletion of all code that does not make any change regarding the error message.

Code: Select all

MODULE Types;
  TYPE
    Actor* = POINTER TO ActorDesc;
    ReadyQ* = POINTER TO ReadyQdesc;
    ActorDesc* = RECORD
      rdyQ*: ReadyQ
    END;
    ReadyQdesc* = RECORD END;
END Types.

MODULE ReadyQueue;
  IMPORT Types;
  TYPE Queue* = Types.ReadyQ;
END ReadyQueue.

MODULE SysCall;
  IMPORT Types, ReadyQueue;
  PROCEDURE RQput*(q: Types.ReadyQ; act: Types.Actor);
  END RQput;
END SysCall.

MODULE Kernel;
  IMPORT Types, SysCall;
  PROCEDURE PutMsg*;
    VAR act: Types.Actor;
  BEGIN
    SysCall.RQput(act.rdyQ, act) (* <= compilation error *)
  END PutMsg;
END Kernel.
Compiling module Kernel fails at 'SysCall.RQput(act.rdyQ, act)' with error message 'Error: incompatible parameters' for 'act.rdyQ'.

Commenting out 'Queue* = Types.ReadyQ;' in module ReadyQueue (or not importing the module) resolves the issue. In the real program, I now omit the type definition in ReadyQueue, resorting to directly using 'Types.ReadyQ'.

Re: Unexpected Compilation Error

Posted: Mon Aug 04, 2025 12:36 am
by cfbsoftware
Thank you for your report - the whole issue of import ordering, re-importing and aliasing is very complex. e.g. another workaround for this example is to change the order of imports in SysCall to:

Code: Select all

IMPORT ReadyQueue, Types;
The IMPORT system was extensively refactored a year or so ago in an attempt to resolve these type of problems but there appears to be some problematic cases remaining. More work to be done ...