Spivoxity / obc-3

Oxford Oberon-2 compiler
38 stars 7 forks source link

Qualified type name as label in typecase #20

Closed Spivoxity closed 5 years ago

Spivoxity commented 5 years ago

Hi, So far, OBC worked flawlessly for me, thanks.

So I wrote something like this :

MODULE m0 ;
TYPE 
   Base * = POINTER TO BaseCell ; 
   Ext1 * = POINTER TO Ext1Cell ;
   Ext2 * = POINTER TO Ext2Cell ;
   BaseCell * = RECORD END ;
   Ext1Cell * = RECORD (BaseCell) stuff1 * : INTEGER END ;
   Ext2Cell * = RECORD (BaseCell) stuff2 * : REAL END ;
END m0.

MODULE m1 ;
IMPORT m0, Out ;

   PROCEDURE buggy(x : m0.Base) ;
   BEGIN
      CASE x OF
           m0.Ext1 :
         | m0.Ext2 :
      END
   END buggy ;

END m1 .

and got the following error message when compiling m1 :

Test : obc -07 -c m0.m # No problem
Test : obc -07 m1.m
"m1.m", line 7: type name expected in type CASE
>            m0.Ext1 :
>            ^^^^^^^

(According to the Oberon 07 report, a case label can indeed be a qualident)

Thanks for your help.

Georges Louis glou47@gmail.com (Retired CS professor, University of La Rochelle)

Spivoxity commented 5 years ago

Thanks for the report; it looks like a bug to me.

A workaround is to define

TYPE Ext1 = m0.Ext1;

in module m1 and then write CASE x OF Ext1: ....

Spivoxity commented 5 years ago

Fixed in 3.0.7