March 22, 2005 no property 'length' for type 'int[]' - error misleading, code should be possible IMO | ||||
---|---|---|---|---|
| ||||
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 |
March 22, 2005 Re: no property 'length' for type 'int[]' - error misleading, code should be possible IMO | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | 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 |
Copyright © 1999-2021 by the D Language Foundation