Browse Source

fcl-passrc: resolver: fixed high(intvar)

git-svn-id: trunk@39906 -
Mattias Gaertner 6 years ago
parent
commit
27a9d53dd2

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

@@ -12577,9 +12577,8 @@ begin
   Param:=Params.Params[0];
   ComputeElement(Param,ParamResolved,[]);
   Result:=cIncompatible;
-  if not (rrfReadable in ParamResolved.Flags)
-      and (ParamResolved.BaseType in btAllRanges) then
-    // built-in range e.g. high(char)
+  if ParamResolved.BaseType in btAllRanges then
+    // e.g. high(char)
     Result:=cExact
   else if ParamResolved.BaseType=btSet then
     Result:=cExact
@@ -12592,7 +12591,12 @@ begin
       Result:=cExact;
     end;
   if Result=cIncompatible then
+    begin
+    {$IFDEF VerbosePasResolver}
+    writeln('TPasResolver.BI_LowHigh_OnGetCallCompatibility ParamResolved=',GetResolverResultDbg(ParamResolved));
+    {$ENDIF}
     exit(CheckRaiseTypeArgNo(20170216152338,1,Param,ParamResolved,'ordinal type, array or set',RaiseOnError));
+    end;
 
   Result:=CheckBuiltInMaxParamCount(Proc,Params,1,RaiseOnError);
 end;

+ 6 - 2
packages/fcl-passrc/tests/tcresolver.pas

@@ -3016,8 +3016,12 @@ begin
   '  MaxInt = +10;',
   'type',
   '  {#TMyInt}TMyInt = MinInt..MaxInt;',
-  'const a = low(TMyInt)+High(TMyInt);',
-  'begin']);
+  'const',
+  '  a = low(TMyInt)+High(TMyInt);',
+  'var',
+  '  i: TMyInt;',
+  'begin',
+  '  i:=low(i)+high(i);']);
   ParseProgram;
   CheckResolverUnexpectedHints;
 end;

+ 4 - 1
packages/pastojs/tests/tcmodules.pas

@@ -5316,7 +5316,9 @@ begin
   '  i: TMyInt;',
   'begin',
   '  i:=-MinInt;',
-  '  i:=default(TMyInt);']);
+  '  i:=default(TMyInt);',
+  '  i:=low(i)+high(i);',
+  '']);
   ConvertProgram;
   CheckSource('TestIntegerRange',
     LinesToStr([
@@ -5328,6 +5330,7 @@ begin
     LinesToStr([
     '$mod.i = - -4503599627370496;',
     '$mod.i = -4503599627370496;',
+    '$mod.i = -4503599627370496 + 4503599627370495;',
     '']));
 end;