Explorar o código

* fix #40305: with type helpers now supporting inheriting from unique type aliases, declare a TRealHelper as a descendant of TDoubleHelper (cause Real is a Double)
+ added test

Sven/Sarah Barth hai 9 meses
pai
achega
2ef822e8e8
Modificáronse 2 ficheiros con 22 adicións e 0 borrados
  1. 5 0
      rtl/objpas/sysutils/syshelph.inc
  2. 17 0
      tests/webtbs/tw40305.pp

+ 5 - 0
rtl/objpas/sysutils/syshelph.inc

@@ -786,6 +786,11 @@ Type
     property Exp: QWord read GetE write SetE;
     property Frac: QWord read GetF write SetF;
   end;
+
+{$IFNDEF VER3_2}
+  TRealHelper = Type Helper(TDoubleHelper) for Real
+  end;
+{$ENDIF}
 {$ENDIF FPC_HAS_TYPE_DOUBLE}
 
 {$ifdef FPC_HAS_TYPE_EXTENDED}

+ 17 - 0
tests/webtbs/tw40305.pp

@@ -0,0 +1,17 @@
+program tw40305;
+
+{$mode objfpc}
+
+uses
+  SysUtils;
+
+var
+  r: Real;
+  s: String;
+begin
+  r := 2.42;
+  FormatSettings.DecimalSeparator:='.';
+  s := r.ToString;
+  if s <> '2.42' then
+    Halt(1);
+end.