D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1171 - Cannot create a static array with the length of a const static array in function scope, D1 only
Summary: Cannot create a static array with the length of a const static array in funct...
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 All
: P2 minor
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2007-04-20 13:26 UTC by Matti Niemenmaa
Modified: 2014-02-16 15:23 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Matti Niemenmaa 2007-04-20 13:26:54 UTC
(Set version to 1.012: there's no 1.013 yet.)

void main() {
	const int[2] foo;
	int[foo.length] bar;
}

Compiling the above results in the error "Error: no property 'length' for type 'int'". No module or line information, hence the "diagnostic" keyword on this bug.

Move the code outside of function scope and/or remove the const from "foo" and the code compiles.

Also, replacing foo.length with mixin("foo.length") works, which is odd.
Comment 2 Don 2010-02-01 00:01:54 UTC
The line number bug was fixed between 1.030 and 1.036.
Removing 'diagnostic' from the warning. Works on D2.
(Actually, I think the bug is that D1 allows you create a const array with no initializer).
Comment 3 yebblies 2013-11-16 23:17:10 UTC
Closing because D1 is no longer supported.