Page 1 of 1

RECORD Fields with Identical Identifier

Posted: Sat Apr 27, 2024 6:32 am
by gray
Via a typo I have come across this (Astrobe for Cortex-M0v 9.1):

Code: Select all

MODULE M;
  TYPE
    R = RECORD
      x: INTEGER;
      x: INTEGER;
      y: INTEGER
    END;

  PROCEDURE p;
    VAR r: R;
  BEGIN
    r.x := 13;
    r.y := 17
  END p;
END M.
Looking at the assembly code for 'p':

Code: Select all

PROCEDURE p;
    VAR r: R;
  BEGIN
.    24    018H  0B500H          push     { lr }
.    26    01AH  0B083H          sub      sp,#12
    r.x := 13;
.    28    01CH  0200DH          movs     r0,#13
.    30    01EH  09001H          str      r0,[sp,#4]
    r.y := 17
  END p;
.    32    020H  02011H          movs     r0,#17
.    34    022H  09002H          str      r0,[sp,#8]
.    36    024H  0B003H          add      sp,#12
.    38    026H  0BD00H          pop      { pc }
It appears the second definition of 'x' "shadows" the first. I don't believe this RECORD definition should be allowed.

Re: RECORD Fields with Identical Identifier

Posted: Sun Apr 28, 2024 11:26 pm
by cfbsoftware
You are right - thank you for bringing it to our attention. It should be reported as a "mult def" compilation error. We have confirmed that it also occurs in the latest v9.2 version which is being released in the next day or so. Hence, for now, It will be documented in the release notes as a "Known problem" and will be fixed in the subsequent release.