Skip to content

Fail to declare 2-dimensional generic array

Summary

Declaring a generic two-dimensional array fails when using the array[dim1,dim2] syntax. Using array[dim1] of array[dim2], however, works.

System Information

  • Operating system: Windows 8.1
  • Processor architecture: x86-64
  • Compiler version: trunk
  • Device: Computer

Steps to reproduce

See example.

Example Project

program Project1;

{$mode objfpc}

type generic TMatrix4<T> = array[0..3] of array [0..3] of T; // works
type generic TAnotherMatrix4<T> = array[0..3,0..3] of T; // "Identifier not found T"

begin
end.

What is the current bug behavior?

The declaration type generic TAnotherMatrix4<T> = array[0..3,0..3] of T fails with an Identifier not found "T" error.

What is the expected (correct) behavior?

The declaration should succeed.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information