Search the Community
Showing results for tags 'inline variables'.
Found 2 results
-
Today was my first attempt to actually use these, but that ended once I placed a Breakpoint on one. Perhaps not news to others.. program Project1; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils; {$INLINE OFF} function NewBytes:TBytes; begin SetLength(Result, 10); end; begin try /// <summary> /// F9 from the Breakpoint will repeat 3 times, once for each Inline Variable /// Uncomment the others to prove my point /// </summary> /// <remarks> /// You can also try F7 or F8 /// </remarks> var Eins := NewBytes; // << Breakpoint var Zwei := NewBytes; var Drei := NewBytes; // var NochEins := NewBytes; // var NochZwei := NewBytes; // var NochDrei := NewBytes; writeln('Something Happened!'); except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end.
- 9 replies
-
- debug
- inline variables
-
(and 1 more)
Tagged with:
-
Generic Dictionary and an inline variable: bug or misuse?
Kryvich posted a topic in RTL and Delphi Object Pascal
Hi, I try to adopt outstanding and free Pas2js transpiler to Delphi language. My main development IDE is Delphi CE Rio, so I decided to try a new Delphi syntax: generic collections and inline variables. And stumbled upon a runtime error. The code (simplified): program TestInlineVarForDictionary; {$APPTYPE CONSOLE} {$R *.res} uses SysUtils, Generics.Collections; procedure TestDictErr; var Dict: TDictionary<string,TObject>; begin Dict := TDictionary<string,TObject>.Create; for var item in Dict do Writeln('Key = ', item.Key, 'Name = ', item.Value.ClassName); end; procedure TestDictOK; var Dict: TDictionary<string,TObject>; item: TPair<string,TObject>; begin Dict := TDictionary<string,TObject>.Create; for item in Dict do Writeln('Key = ', item.Key, 'Name = ', item.Value.ClassName); end; begin try //!!TestDictOK; TestDictErr; except on E: Exception do begin Writeln(E.ClassName, ': ', E.Message); Write('Press Enter to continue...'); Readln; end; end; end. This program causes Exception class $C0000005 with message 'access violation at 0x0040a86e: write of address 0x0040a29e'. Can you confirm it? Is it a bug in the compiler or/and RTL, or am I misusing the new syntax? It's interesting: if you uncomment TestDictOK that does enumeration in old-style, the exception will disappear!- 3 replies
-
- tdictionary
- inline variables
-
(and 2 more)
Tagged with: