Jump to content
Excelsior Forums
Sign in to follow this  
excbv

Oberon-2 compiler: error in with statement compilation?

Recommended Posts

The following produces a compiler error:

<* MAIN+ *>

MODULE Test;

IMPORT D:=DStrings;

 

TYPE

  PRec0=POINTER TO Rec0;

  Rec0=RECORD next:PRec0 END;

  PArray1=POINTER TO Array1;

  Array1=ARRAY OF PRec0;

  PRec1=POINTER TO Rec1;

  Rec1=RECORD(Rec0)

    pPR:PArray1

  END;

  PRec2=POINTER TO Rec2;

  Rec2=RECORD(Rec0) d:D.String END;

PROCEDURE DemError();

  VAR  v:PRec1;

  BEGIN

    WITH v.pPR[0] : PRec1 DO    (*!!! repl with ln below, and no error*)

    (*IF v.pPR[0] IS PRec1 THEN*)

  | v.pPR[0] : PRec2 DO        (*!!! repl with ln below, and no error*)

    (*ELSIF v.pPR[0] IS PRec2 THEN*)

    ELSE

    END

  END DemError;

END Test.

project file:

-gendebug+

-lineno+

-o2extensions+

-m2extensions+

-o2addkwd+

-m2addtypes+

-USEDLL+

-GENDLL-

-IMPLIB-

-MINCPU=PENTIUM

-CPU=PENTIUM

-MAKEDEF-

-XCOMMENTS-

-O2ISOPRAGMA+

-PROCINLINE+

!module Test

Can someone verify and comment?

Regards,

excbv

Share this post


Link to post
Share on other sites
The following produces a compiler error:

Did you mean "a compilation error"? Or did you actually see a compiler crash?

Can someone verify and comment?

It would be helpful if you posted the error you saw. Just to be on the same page.

I see E054: "object is not variable", which is perfectly valid in this context, see Oberon-2 Report.

The following code will compile:

PROCEDURE DemError();
  VAR  v:PRec1; tmp: PRec0;
  BEGIN
    tmp := v.pPR[0];
    WITH tmp : PRec1 DO    (*!!! repl with ln below, and no error*)
    (*IF v.pPR[0] IS PRec1 THEN*)
  | tmp : PRec2 DO         (*!!! repl with ln below, and no error*)
    (*ELSIF v.pPR[0] IS PRec2 THEN*)
    ELSE
    END
  END DemError;

Share this post


Link to post
Share on other sites

Hello,

(compilation error? YES)

Thanks for your answer. I suppose you are right. I guess I assumed that

the with statement WITH v:T DO allowed v to be a _designator_  rather

than _variable_ (as is stated in the report). When one thinks about

this limitation, it is probably due to the fact that allowing designators

would require too much run-time information (e.g., for every element

of an array).

Regards,

excbv

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×