[PATCH] Static array initialization from array constructor
Original Reporter info from Mantis: ryan_joseph @genericptr
-
Reporter name: Ryan Joseph
Original Reporter info from Mantis: ryan_joseph @genericptr
- Reporter name: Ryan Joseph
Description:
It appears to be a very trivial task to get the compiler to accept array constructors to initialize static arrays (a long wished for feature for me) so I made a first draft attempt at implementing this, although I'm not sure how to handle managed types.
Can anyone explain what needs to happen conceptually when an array constructor with managed types is assigned to a static array? For static to static array assignments I think only fpc_copy_proc is called and that is sufficient to handle everything, but do I need to do more for array constructors? In typecheck_arrayconstructor_to_array() (from ncnv.pas) you can see I made a template which mimics how dynamic arrays are converted but I think this increased the ref count too high when compared to doing nothing and allowing fpc_copy_proc to handle it.
Thank you, please advise and I'll finish the patch.
Additional information:
An example:
var
a: array[0..2] of integer;
begin
a := [1,2,3];
end.
Mantis conversion info:
- Mantis ID: 36909
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 46891 (#2ff18e48)
- Monitored by: » @CuriousKit (J. Gareth Moreton), » @PascalDragon (Sven Barth)