vishapoberon / compiler

vishap oberon compiler
http://oberon.vishap.am
GNU General Public License v3.0
186 stars 25 forks source link

parameter doesn't match (SYSTEM.ADDRESS) #79

Open aixp opened 4 years ago

aixp commented 4 years ago
MODULE A;

    IMPORT SYSTEM;

    TYPE
        T* = PROCEDURE (adr: SYSTEM.ADDRESS);

    PROCEDURE P* (t: T);
    BEGIN
    END P;

END A.
MODULE B;

    IMPORT SYSTEM, A;

    PROCEDURE P0 (adr: SYSTEM.ADDRESS);
    BEGIN
    END P0;

    PROCEDURE P;
    BEGIN
        A.P(P0)
    END P;

END B.
$ voc A.Mod B.Mod
A.Mod  Compiling A.  New symbol file.  339 chars.
B.Mod  Compiling B.

  11:       A.P(P0)
             ^
    pos   113  err 115  parameter doesn't match

Module compilation failed.
$ voc | head -2 | tail -1
Oberon-2 compiler v2.1.0 [2019/11/15] for gcc LP64 on ubuntu.
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 19.04
Release:    19.04
Codename:   disco
dcwbrown commented 4 years ago

Yes. Reproduces for me. I agree - I think it should work.

Here's a workaround:

MODULE A;
IMPORT SYSTEM;

TYPE
  ADDRESS* = SYSTEM.ADDRESS;
  T* = PROCEDURE (adr: ADDRESS);

  PROCEDURE P*(t: T);
  BEGIN
  END P;

END A.
MODULE B;
IMPORT SYSTEM, A;

  PROCEDURE P0(adr: A.ADDRESS);
  BEGIN
  END P0;

  PROCEDURE P;
  BEGIN
    A.P(P0)
  END P;

END B.
voc -s a.mod b.mod -m
a.mod  Compiling A.  340 chars.
b.mod  Compiling B.  Main program.  449 chars.

Will this work for you?

It may be the symbol fingerprinting code, that took me a long time to understand last time I needed to work on it, and I've forgotten everything I knew :-(.

Or it may be deeper - I think PROCEDURE type equivalence has some special case code.

-- Dave.

aixp commented 4 years ago

Yes, it works for me.