Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2013-02

FPC-JVM: Problem with "with" in nested records

4 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Nicola

Hello everyone! I'm working on a framework that remaps all controls native iOS and Android (TMLabel = TLabel in win, UILabel in iOS, TextView in Android, etc). Congratulations to the compiler Jvm, allows me to use a lot of Pascal code in Android, but I found a problem with nested command "with". I built ppcjvm with revision 23596. This is the sample code:

type
   TRec1 = record
       a: integer;
   end;
   TRec2 = record
     i: integer;
     Rec1: TRec1;
   end;
   TMyClass = class
   protected
     Data: TRec2;
   public
     procedure Test;
   end;
procedure TMyClass.Test;
var
     LocData: TRec2;
begin
     with LocData do
         Rec1.a := 123;
     Log('with: ' + IntToStr(LocData.Rec1.a));            // success, it
shows 123
     LocData.Rec1.a := 124;
     Log('not with: ' + IntToStr(LocData.Rec1.a));        // success it
shows 124
     with Data do
         Rec1.a := 123;
     Log('with: ' + IntToStr(Data.Rec1.a));            // !!FAIL!!, it
shows 0
     Data.Rec1.a := 124;
     Log('not with: ' + IntToStr(Data.Rec1.a));        // success it
shows 124
end;
Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f Sponsor: Su MisterCupido.com puoi creare REGALI PERSONALIZZATI. Stampa le tue Foto su: Cuscini, Tazze, Puzzle, Peluche, Magliette, Poster... Consegne in tutta Italia in soli 2-3 giorni Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=12385&d=12-2

Reply by email

Paul Ishenin
to Nicola
Nicola wrote
Rec1.a := 123; Log('with: ' + IntToStr(Data.Rec1.a)); // !!FAIL!!, it shows 0

Non JVM compiler outputs 123. So indeed a JVM compiler bug.

Best regards,
Paul Ishenin

Reply by email

Mark Morgan Lloyd
to Michael Schnell
Michael Schnell wrote
On 02/12/2013 11:58 AM, Nicola wrote: > t I found a problem with nested command "with". When reading code with nested with statements I get confused as well :-P .

Wouldn't help in the current case, but some way of setting an alias would be nice.

with desc: TFingerRequest=
TFingerRequest(LeftPane.Items[GreenBranch].Data).Description do begin

     desc.Append(Custom.Format(green_1, []));
     desc.Append(Custom.Format(green_2, []));

..

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email