rochus-keller / Oberon

Oberon parser, code model & browser, compiler and IDE with debugger, and an implementation of the Oberon+ programming language
GNU General Public License v2.0
463 stars 30 forks source link

Problems with type extension #47

Closed wrightsl closed 9 months ago

wrightsl commented 9 months ago

The following small excerpt illustrates the problem:

MODULE Test;

CONST NullInteger* = MIN(LONGINT);

TYPE Element = POINTER TO ElementDesc; ElementDesc = RECORD END;

IntElement* = POINTER TO IntElementDesc;
IntElementDesc* = RECORD (ElementDesc)
  value*:LONGINT
END;

VAR SentinelElement:Element; SentinelIntElement:IntElement;

PROCEDURE (le:Element) InitElement*(); BEGIN END InitElement;

PROCEDURE NewElement*():Element; VAR el:Element; BEGIN NEW(el); el.InitElement(); RETURN el END NewElement;

PROCEDURE (le:IntElement) InitIntElement*(initialValue:LONGINT); BEGIN le.InitElement(); le.value := initialValue END InitIntElement;

PROCEDURE NewIntElement*(initialValue:LONGINT):IntElement; VAR le:IntElement; BEGIN NEW(le); le.InitIntElement(initialValue); RETURN le END NewIntElement;

BEGIN SentinelElement := NewElement(); SentinelIntElement := NewIntElement(NullInteger) END Test.

The compiler complains that the receiver (le:Element) must be of record or pointer to record type. This code compiles correctly on several different oberon versions. I have been using the Linz system for some time but have hit a limit of modules and imports with my large and growing software system so I thought I would try your system, but failed at the first hurdle. Please help

wrightsl commented 9 months ago

P.S. I am using the http://software.rochus-keller.ch/OberonIDE_linux_x86_64.tar.gz file downloaded from here.

wrightsl commented 9 months ago

Compiling your wikipedia_example_in_Oberon+/Lists_v0.mod gives the same problem. Is there some environment or compiler setting I should be using?

rochus-keller commented 9 months ago

Thanks for the report. I confirm that this is indeed an issue. Looks like I have introduced it in a more recent commit without noticing. I will commit a fix asap.

rochus-keller commented 9 months ago

Ok, the commit 9c856728a8a2f1fe6931533eaec28d7dcfea3d95 from June 2023 seems to have caused the issue (which went into the precompiled versions by October 2023). registerBoundProc is called too early, i.e. before the pointer is resolved. I will check the fix with all my test projects and commit it later the day. Can you compile the IDE yourself, or do you depend on precompiled binaries?

rochus-keller commented 9 months ago

The issue is solved and the commit is up: https://github.com/rochus-keller/Oberon/commit/384b00bcbd0d7dd8057bcee8f7e9c02e46934826.

I will check whether I can do a rebuild of the x64 Linux binary.

rochus-keller commented 9 months ago

I uploaded a new Linux x64 version, in case you want to try it: http://software.rochus-keller.ch/OberonIDE_linux_x86_64.tar.gz

wrightsl commented 9 months ago

Thanks for your quick response