gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Error with procedure variable ?


From: Michael Riedl
Subject: Error with procedure variable ?
Date: Tue, 28 Nov 2023 23:20:25 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:102.0) Gecko/20100101 Thunderbird/102.11.0

Gaius,

the following short sample

DEFINITION MODULE Deklera;

CONST MaxDim = 2048;

TYPE  VEKTOR = ARRAY [1..MaxDim] OF REAL;
      MATRIX = ARRAY [1..MaxDim] OF VEKTOR;

END Deklera.

----------

MODULE TstMat;

FROM Deklera  IMPORT MaxDim,MATRIX;

PROCEDURE TA(VAR A : ARRAY OF ARRAY OF REAL;
                 N : CARDINAL);

          VAR i,j : CARDINAL;
BEGIN
      FOR i:=0 TO N-1 DO
        FOR j:=0 TO N-1 DO A[i,j] := 0.0; END;
      END;
END TA;

PROCEDURE TB(VAR A : ARRAY OF ARRAY OF REAL;
                 N : CARDINAL);

          VAR i,j : CARDINAL;
BEGIN
      FOR i:=0 TO N-1 DO
        FOR j:=0 TO N-1 DO A[i,j] := 1.0; END;
      END;
END TB;

TYPE  TX = PROCEDURE(VAR ARRAY OF ARRAY OF REAL,
                         CARDINAL);

VAR   Tx : TX;

VAR   N  : CARDINAL;
      A  : MATRIX;
      B  : ARRAY [0..MaxDim-1] OF ARRAY [0..MaxDim-1] OF REAL;
BEGIN
      Tx := TA;
      Tx(A,N);

      Tx := TB;
      Tx(B,N);

      TA(A,N);
      TB(B,N);

END TstMat.


shows the following errors (GM2 version 13.2.1 20231123) :

mriedl@laptop:~/Modula-2/GM2/bug2$gm2 TstMat.mod
TstMat.mod:25:48: error: In program module 'TstMat': PROCEDURE TX (VAR : ARRAY OF REAL; ... ) ;
   25 | TYPE  TX = PROCEDURE(VAR ARRAY OF ARRAY OF REAL,
      |                                                ^
TstMat.mod:25:48: error: PROCEDURE TX (VAR : ARRAY OF REAL; ... ) ;
TstMat.mod:31:7: error: no scope active: item being passed is variable 'A' of type 'MATRIX'
   31 |       A  : MATRIX;
      |       ^
TstMat.mod:32:7: error: item being passed is variable 'B' of type Bvariable
   32 |       B  : ARRAY [0..MaxDim-1] OF ARRAY [0..MaxDim-1] OF REAL;
      |       ^
TstMat.mod:35:10: error: In program module 'TstMat': PROCEDURE TX (VAR : ARRAY OF REAL; ... ) ;
   35 |       Tx(A,N);
      |          ^
TstMat.mod:35:14: error: parameter mismatch between the 1st parameter of procedure 'TX'
   35 |       Tx(A,N);
      |              ^
TstMat.mod:38:10: error: PROCEDURE TX (VAR : ARRAY OF REAL; ... ) ;
   38 |       Tx(B,N);
      |          ^
TstMat.mod:38:14: error: parameter mismatch between the 1st parameter of procedure 'TX'
   38 |       Tx(B,N);
      |              ^

which, to my understanding, is a bug (if the procedures are called directly - last two statements - no claims).


Thanks in advance

Gruß

Michael





reply via email to

[Prev in Thread] Current Thread [Next in Thread]