Browse Source

fcl-passrc: fixed passing dynarray to var param open array

git-svn-id: trunk@42826 -
Mattias Gaertner 6 years ago
parent
commit
1168083dfe
2 changed files with 13 additions and 0 deletions
  1. 7 0
      packages/fcl-passrc/src/pasresolver.pp
  2. 6 0
      packages/fcl-passrc/tests/tcresolver.pas

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

@@ -23202,6 +23202,13 @@ begin
         else
           exit(cAliasExact);
         end;
+      if (ParamResolved.BaseType=btContext)
+          and (ParamResolved.LoTypeEl.ClassType=TPasArrayType)
+          and (ExprResolved.LoTypeEl.ClassType=TPasArrayType) then
+        begin
+        Result:=CheckAssignResCompatibility(ParamResolved,ExprResolved,Expr,false);
+        if Result<>cIncompatible then exit;
+        end;
       end;
     if RaiseOnError then
       RaiseIncompatibleTypeRes(20170216152452,nIncompatibleTypeArgNoVarParamMustMatchExactly,

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

@@ -14510,6 +14510,10 @@ begin
   'type',
   '  TDynArrInt = array of byte;',
   '  TStaArrInt = array[1..2] of byte;',
+  'procedure Fly(var a: array of byte);',
+  'begin',
+  '  Fly(a);',
+  'end;',
   'procedure DoIt(a: array of byte);',
   'var',
   '  d: TDynArrInt;',
@@ -14520,6 +14524,8 @@ begin
   '  // d:=a; forbidden in delphi',
   '  DoIt(d);',
   '  DoIt(s);',
+  '  Fly(a);',
+  '  Fly(d);', // dyn array can be passed to a var open array
   'end;',
   'begin',
   '']);