Browse Source

* dont' allow assignments to array of const, resolves #41230

florian 3 tháng trước cách đây
mục cha
commit
4cae231a52
2 tập tin đã thay đổi với 12 bổ sung1 xóa
  1. 1 1
      compiler/nld.pas
  2. 11 0
      tests/webtbf/tw41230.pp

+ 1 - 1
compiler/nld.pas

@@ -746,7 +746,7 @@ implementation
           maybe_call_procvar(right,true);
 
         { assignments to formaldefs and open arrays aren't allowed }
-        if is_open_array(left.resultdef) then
+        if is_open_array(left.resultdef) or is_array_of_const(left.resultdef) then
           begin
             CGMessage(type_e_assignment_not_allowed);
             result:=cerrornode.create;

+ 11 - 0
tests/webtbf/tw41230.pp

@@ -0,0 +1,11 @@
+{ %fail }
+program app;
+{$mode objfpc}
+
+procedure test(a: array of const);
+begin
+  a := [1, 2, 3];
+end;
+
+begin
+end.