RECORD Fields with Identical Identifier

Report any suspected bugs that you find
Post Reply
gray
Posts: 120
Joined: Tue Feb 12, 2019 2:59 am
Location: Mauritius

RECORD Fields with Identical Identifier

Post by gray » Sat Apr 27, 2024 6:32 am

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.

cfbsoftware
Site Admin
Posts: 501
Joined: Fri Dec 31, 2010 12:30 pm
Contact:

Re: RECORD Fields with Identical Identifier

Post by cfbsoftware » Sun Apr 28, 2024 11:26 pm

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.

Post Reply