tebe6502 / Mad-Pascal

Mad Pascal Compiler for 6502 (Atari XE/XL, C64, C4Plus, Neo6502)
122 stars 20 forks source link

Unable to cast pointer on the left side of assignment #99

Closed SignumTemporis closed 2 years ago

SignumTemporis commented 2 years ago

Issue description

An attempt to cast a pointer on the left side of an assignment causes compilation error.

A workaround is to use a local variable with proper type but it consumes memory.

For FPC -MDelphi v3.2.2 it works as expected.

Mad-Pascal Compiler version 9cc0813 Mad-Assembler version 40bfd80

Code to reproduce the issue

uses crt;

type
  Box = record x: Byte end;
  BoxPtr = ^Box;

var data: array [0 .. 1] of Byte;

procedure DoSomething(p: Pointer);
begin
  BoxPtr(p)^.x := BoxPtr(p)^.x + 1;
end;

begin
  data[0] := 10;  data[1] := 20;

  DoSomething(@data);
  WriteLn(data[0], ' ', data[1]);

  ReadKey();
end.

Output

Expected

11 20

Actual

test.pas (11,6) Error: Variable identifier expected
tebe6502 commented 2 years ago

fixed

SignumTemporis commented 2 years ago

Works for me now.