nielsAD / lape

Scripting engine with Pascal-like syntax for FPC and Delphi
119 stars 28 forks source link

Not sure if it is a bug, or me... #110

Closed 3FLLC closed 6 years ago

3FLLC commented 6 years ago

This code snippet two ANSI Strings are acting like they are pointers to the same memory address...

{$R-} procedure TestChar(var c: Char); begin c := 'u'; end;

procedure TestStr(s: String); begin s[2] := 'u'; end;

var s1, s2: AnsiString; begin s1 := 'wat'; s2 := s1; TestStr(s1); Assert(s1[2] = 'a'); Assert(s2[2] = 'a');

s1 := 'wat'; s2 := s1; s1[2] := 'u'; Assert(s1[2] = 'u'); Assert(s2[2] = 'a');

s1 := 'wat'; s2 := s1; Writeln(s1); Writeln(s2); TestChar(s1[2]); Writeln(s1); Writeln(s2); Assert(s1[2] = 'u'); Assert(s2[2] = 'u'); Writelns1); Writeln(s2); end.

The Writeln's say: wat wat wut wut wut wut

FPC does not produce this same output.

nielsAD commented 6 years ago

It's a known issue, see issue #85.