D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6655 - Forward error with static array length
Summary: Forward error with static array length
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 critical
Assignee: No Owner
URL:
Keywords: diagnostic, rejects-valid
Depends on:
Blocks:
 
Reported: 2011-09-12 15:47 UTC by bearophile_hugs
Modified: 2012-04-24 00:49 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 bearophile_hugs 2011-09-12 15:47:11 UTC
D2 code:


enum size_t N = 1;
int[bar.length] foo;
int[N] bar;
void main() {}


DMD 2.055 gives:

Error: cannot create associative array int[N]


This is a very nice bug. There are three problems here: refusing valid code, thinking bar is an associative array instead of a fixed-sized one, and giving no line number.
Comment 1 yebblies 2011-09-14 06:01:52 UTC
The problem here is that TypeAArray::getImpl is being called on bar before semantic has, therefore there is no scope or location.  Of the three problems, the lack of scope causes the failure to lookup N (and therefore the failure to recognize bar as a static array), and also the lack of a file/line number.
Comment 3 Walter Bright 2012-04-24 00:49:03 UTC
Works in 2.059.