Browse Source

* do not throw an internal error if slice is used on dyn. array paramters, resolves #39806

florian 3 năm trước cách đây
mục cha
commit
8eb2cea349
2 tập tin đã thay đổi với 21 bổ sung1 xóa
  1. 3 1
      compiler/ninl.pas
  2. 18 0
      tests/webtbf/tw39806.pp

+ 3 - 1
compiler/ninl.pas

@@ -4179,7 +4179,9 @@ implementation
             end;
             end;
 
 
           in_slice_x:
           in_slice_x:
-            internalerror(2005101502);
+            { slice can be used only in calls for open array parameters, so it has to be converted appropriatly before
+              if we get here, the array could not be passed to an open array parameter so it is an error }
+            CGMessagePos(left.fileinfo,type_e_mismatch);
 
 
           in_ord_x,
           in_ord_x,
           in_chr_byte:
           in_chr_byte:

+ 18 - 0
tests/webtbf/tw39806.pp

@@ -0,0 +1,18 @@
+{ %fail }
+program test;
+
+type
+  TByteDynArr = array of byte;
+
+procedure proc(a: TByteDynArr);
+begin
+  Writeln(Length(a));
+end;
+
+var
+  x: array of byte;
+begin
+  x:= [1,2,3,4];
+  proc(Slice(x, 2));
+  // <source>(15,19) Fatal: Internal error 2005101501
+end.