mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 21:29:42 +02:00
* fix #40725: pass along whole array constructor to the Insert() so that it's converted with the correct checks
+ added test
This commit is contained in:
parent
e76c5d96d8
commit
b0d61558e3
@ -1988,7 +1988,7 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
elem : tnode;
|
constr : tnode;
|
||||||
para : tcallparanode;
|
para : tcallparanode;
|
||||||
isarrconstrl,
|
isarrconstrl,
|
||||||
isarrconstrr : boolean;
|
isarrconstrr : boolean;
|
||||||
@ -2017,14 +2017,14 @@ implementation
|
|||||||
if isarrconstrl then
|
if isarrconstrl then
|
||||||
begin
|
begin
|
||||||
index:=0;
|
index:=0;
|
||||||
elem:=tarrayconstructornode(left).left;
|
constr:=left;
|
||||||
tarrayconstructornode(left).left:=nil;
|
left:=nil;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
index:=high(asizeint);
|
index:=high(asizeint);
|
||||||
elem:=tarrayconstructornode(right).left;
|
constr:=right;
|
||||||
tarrayconstructornode(right).left:=nil;
|
right:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ we use the fact that insert() caps the index to avoid a copy }
|
{ we use the fact that insert() caps the index to avoid a copy }
|
||||||
@ -2033,7 +2033,7 @@ implementation
|
|||||||
ccallparanode.create(
|
ccallparanode.create(
|
||||||
aktassignmentnode.left.getcopy,
|
aktassignmentnode.left.getcopy,
|
||||||
ccallparanode.create(
|
ccallparanode.create(
|
||||||
elem,nil)));
|
constr,nil)));
|
||||||
|
|
||||||
result:=cinlinenode.create(in_insert_x_y_z,false,para);
|
result:=cinlinenode.create(in_insert_x_y_z,false,para);
|
||||||
include(aktassignmentnode.assignmentnodeflags,anf_assign_done_in_right);
|
include(aktassignmentnode.assignmentnodeflags,anf_assign_done_in_right);
|
||||||
|
30
tests/webtbf/tw40725.pp
Normal file
30
tests/webtbf/tw40725.pp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{ %FAIL }
|
||||||
|
|
||||||
|
program tw40725;
|
||||||
|
|
||||||
|
{$mode delphi}
|
||||||
|
{$ModeSwitch functionreferences}
|
||||||
|
|
||||||
|
type
|
||||||
|
TMyProc = reference to procedure(const A: Integer; const B: string);
|
||||||
|
TMyProcArray = array of TMyProc;
|
||||||
|
|
||||||
|
function GetArray: TMyProcArray;
|
||||||
|
procedure MyProc(const A: TObject);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
begin
|
||||||
|
//Result := [MyProc]; // compiler error -> OK
|
||||||
|
Result := Result + [MyProc]; // NO COMPILER ERROR -> BUG
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
A: TMyProcArray;
|
||||||
|
P: TMyProc;
|
||||||
|
begin
|
||||||
|
A := GetArray;
|
||||||
|
for P in A do
|
||||||
|
P(1, '');
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user