TStringBuilder.toString bug
<!-- See available text formatting: https://gitlab.com/help/user/markdown.md --> ## Summary Instead of method calling, the result of the function is accessed. Related to https://gitlab.com/freepascal.org/fpc/source/-/issues/41632 ## Steps to reproduce ```pascal program Project1; {$mode delphi} uses SysUtils; function GetStr: string; var sb: TStringBuilder; begin sb := TStringBuilder.Create; try sb.Append('Hello, world'); Result := sb.ToString(False); finally sb.Free; end; end; begin WriteLn(GetStr()); readln; end. ``` Print nothing instead of 'Hello, world' ## Possible fixes ``` rtl/objpas/sysutils/syssb.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtl/objpas/sysutils/syssb.inc b/rtl/objpas/sysutils/syssb.inc index b4f4c8d01a..56d4e4e49e 100644 --- a/rtl/objpas/sysutils/syssb.inc +++ b/rtl/objpas/sysutils/syssb.inc @@ -709,7 +709,7 @@ function TGenericStringBuilder.ToString(UpdateCapacity: Boolean): SBString; begin if (Length<>Capacity) and UpdateCapacity then SetCapacity(Length); - Result:=ToString; + Result:=ToString(); end; ```
issue