https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112911

            Bug ID: 112911
           Summary: Problem creating aggregate constants containing a
                    variant record
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: modula2
          Assignee: gaius at gcc dot gnu.org
          Reporter: gaius at gcc dot gnu.org
  Target Milestone: ---

Forwarded from the gm2 mailing list:

The following code:

MODULE constvarient ;                                                           

TYPE                                                                            
   ParsedDigit = RECORD                                                         
                    CASE Valid: BOOLEAN OF                                      
                    TRUE: Value: CARDINAL;                                      
                    ELSE                                                        
                    END;                                                        
                 END;                                                           

CONST                                                                           
   PD1 = ParsedDigit { TRUE, 1 } ;                                              
   PD2 = ParsedDigit { FALSE };                                                 

VAR                                                                             
   d1, d2: ParsedDigit ;                                                        
BEGIN                                                                           
   d1 := PD1 ;                                                                  
   d2 := PD2                                                                    
END constvarient.

is rejected by gm2:

$ gm2 constvarient.mod                                                          
constvarient.mod:12:8: error: trying to construct a compound literal and using
a record field which does not exist                                             
   12 |    PD1 = ParsedDigit { TRUE, 1 } ;                                      
      |    ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~                                        
constvarient.mod:13:8: error: trying to construct a compound literal and using
a record field which does not exist                                             
   13 |    PD2 = ParsedDigit { FALSE };                                         
      |    ~~~~^~~~~~~~~~~~~~~~~~~~~~~                                          
constvarient.mod:18:7: error: trying to construct a compound literal and using
a record field which does not exist                                             
   18 |    d1 := PD1 ;                                                          
      |    ~~~^~~~~~                                                            
constvarient.mod:19:7: error: trying to construct a compound literal and using
a record field which does not exist                                             
   19 |    d2 := PD2                                                            
      |    ~~~^~~~~~

Reply via email to