浏览代码

* 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 9 月之前
父节点
当前提交
2ef822e8e8
共有 2 个文件被更改,包括 22 次插入0 次删除
  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 Exp: QWord read GetE write SetE;
     property Frac: QWord read GetF write SetF;
     property Frac: QWord read GetF write SetF;
   end;
   end;
+
+{$IFNDEF VER3_2}
+  TRealHelper = Type Helper(TDoubleHelper) for Real
+  end;
+{$ENDIF}
 {$ENDIF FPC_HAS_TYPE_DOUBLE}
 {$ENDIF FPC_HAS_TYPE_DOUBLE}
 
 
 {$ifdef FPC_HAS_TYPE_EXTENDED}
 {$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.