www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - no property 'length' for type 'int[]' - error misleading, code should be possible IMO

reply "Regan Heath" <regan netwin.co.nz> writes:
I think that this code should be possible, and that the current error is  
misleading.

[test23.d]
int[] arr = [0,1,2,3];
int[arr.length] arr2;

void main()
{	
}

C:\Library\D\src\temp\test23.d(2): no property 'length' for type 'int[]'

The same occurs for a static array.

[test23.d]
int[4] arr = [0,1,2,3];
int[arr.length] arr2;

void main()
{	
}

C:\Library\D\src\temp\test23.d(2): no property 'length' for type 'int[4]'

I think that (at least) this latter example should be valid. Ideally both  
examples should be valid code as the length is clearly known at compile  
time.

In fact:

[test23.d]
int[] arr;
int[arr.length] arr2;

void main()
{	
}

would also technically be valid assuming "int[0] arr2;" was valid.

Regan
Mar 21 2005
parent Derek Parnell <derek psych.ward> writes:
On Tue, 22 Mar 2005 12:22:01 +1200, Regan Heath wrote:

 I think that this code should be possible, and that the current error is  
 misleading.
 
 [test23.d]
 int[] arr = [0,1,2,3];
 int[arr.length] arr2;
 
 void main()
 {	
 }
 
 C:\Library\D\src\temp\test23.d(2): no property 'length' for type 'int[]'
 
 The same occurs for a static array.
 
 [test23.d]
 int[4] arr = [0,1,2,3];
 int[arr.length] arr2;
 
 void main()
 {	
 }
 
 C:\Library\D\src\temp\test23.d(2): no property 'length' for type 'int[4]'
 
 I think that (at least) this latter example should be valid. Ideally both  
 examples should be valid code as the length is clearly known at compile  
 time.
 
 In fact:
 
 [test23.d]
 int[] arr;
 int[arr.length] arr2;
 
 void main()
 {	
 }
 
 would also technically be valid assuming "int[0] arr2;" was valid.
 

Yep, I think you're right. Should be possible. -- Derek Melbourne, Australia 22/03/2005 11:28:32 AM
Mar 21 2005