Browse Source

fcl-passrc: resolver: int64(currency)

git-svn-id: trunk@39942 -
Mattias Gaertner 6 years ago
parent
commit
3f08a6c05c
2 changed files with 14 additions and 3 deletions
  1. 3 3
      packages/fcl-passrc/src/pasresolver.pp
  2. 11 0
      packages/fcl-passrc/tests/tcresolver.pas

+ 3 - 3
packages/fcl-passrc/src/pasresolver.pp

@@ -16208,7 +16208,7 @@ begin
         else
           begin
           {$IFDEF VerbosePasResEval}
-          writeln('TPasResolver.CheckAssignExprRange ',Frac(TResEvalFloat(RValue).FloatValue),' ',TResEvalFloat(RValue).FloatValue<MaxPrecFloat(low(MaxPrecInt)),' ',TResEvalFloat(RValue).FloatValue>MaxPrecFloat(high(MaxPrecInt)),' ',TResEvalFloat(RValue).FloatValue,' ',high(MaxPrecInt));
+          writeln('TPasResolver.CheckAssignExprRange ',Frac(TResEvalFloat(RValue).FloatValue),' ',TResEvalFloat(RValue).FloatValue<TMaxPrecFloat(low(TMaxPrecInt)),' ',TResEvalFloat(RValue).FloatValue>TMaxPrecFloat(high(TMaxPrecInt)),' ',TResEvalFloat(RValue).FloatValue,' ',high(TMaxPrecInt));
           {$ENDIF}
           RaiseRangeCheck(20170802133750,RHS);
           end;
@@ -16222,7 +16222,7 @@ begin
         else
           begin
           {$IFDEF VerbosePasResEval}
-          writeln('TPasResolver.CheckAssignExprRange ',Frac(TResEvalCurrency(RValue).Value),' ',TResEvalCurrency(RValue).Value,' ',high(MaxPrecInt));
+          writeln('TPasResolver.CheckAssignExprRange ',Frac(TResEvalCurrency(RValue).Value),' ',TResEvalCurrency(RValue).Value,' ',high(TMaxPrecInt));
           {$ENDIF}
           RaiseRangeCheck(20180421171438,RHS);
           end;
@@ -18628,7 +18628,7 @@ begin
           Result:=cExact
         else if ToTypeBaseType in btAllInteger then
           begin
-          if FromResolved.BaseType in (btArrayRangeTypes+[btRange]) then
+          if FromResolved.BaseType in (btArrayRangeTypes+[btRange,btCurrency]) then
             Result:=cCompatible
           else if FromResolved.BaseType=btContext then
             begin

+ 11 - 0
packages/fcl-passrc/tests/tcresolver.pas

@@ -2791,7 +2791,10 @@ begin
   '  c=double(currency(-123456890123456));',
   '  d=currency(-1);',
   '  e=currency(word(-1));',
+  'var',
   '  i: longint = 1;',
+  '  i64: int64;',
+  '  f: double;',
   'begin',
   '  a:=i;',
   '  a:=i+a;',
@@ -2807,6 +2810,14 @@ begin
   '  a:=i*a;',
   '  a:=a/i;',
   '  a:=i/a;',
+  '  a:=i64;',
+  '  a:=currency(i64);',
+  //'  i64:=a;', not allowed
+  '  i64:=int64(a);', // truncates a
+  '  a:=f;',
+  '  a:=currency(f);',
+  '  f:=a;',
+  '  f:=double(a);',
   '']);
   ParseProgram;
   CheckResolverUnexpectedHints;