fpc/tests/test/tgeneric25.pp
paul 55a0fefb1f compiler: implement generic array type:
- add tarraysymtable to store generic type symbols
  - process generic and specialize declarations similar to generic records and classes
  - fix insert_generic_parameter_types to use def passed in argument instead of current_structdef because generic array type can't be assigned to the current_structdef variable
  - increase ppu version because of arraydef changes
  - tests

git-svn-id: trunk@16681 -
2011-01-02 13:16:17 +00:00

35 lines
661 B
ObjectPascal

program tgeneric25;
{$mode objfpc}{$H+}
type
generic TArr<T> = array[0..2] of T;
generic TDynamicArr<T> = array of T;
generic TRecArr<T> = array[0..1] of record
A: T;
B: String;
end;
var
ArrInt: specialize TArr<Integer>;
ArrStr: specialize TArr<String>;
DynArrInt: specialize TDynamicArr<Integer>;
RecArr: specialize TRecArr<Integer>;
begin
ArrInt[0] := 1;
ArrStr[0] := '1';
SetLength(DynArrInt, 1);
DynArrInt[0] := 2;
RecArr[0].A := 3;
RecArr[0].B := '3';
if ArrInt[0] <> 1 then
halt(1);
if ArrStr[0] <> '1' then
halt(2);
if DynArrInt[0] <> 2 then
halt(3);
if RecArr[0].A <> 3 then
halt(4);
end.