4019 – [CTFE] Adding an item to an empty AA

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4019 - [CTFE] Adding an item to an empty AA
Summary: [CTFE] Adding an item to an empty AA
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
Reported: 2010年03月28日 06:30 UTC by bearophile_hugs
Modified: 2012年11月14日 01:38 UTC (History)
3 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2010年03月28日 06:30:20 UTC
Problem found in dmd 2.042. This doesn't compile:
int foo() {
 int[int] aa;
 aa[1] = 2;
 return 0;
}
enum _ = foo();
void main() {}
Giving the errors:
test.d(3): Error: Cannot index null array aa
test.d(6): Error: cannot evaluate foo() at compile time
test.d(6): Error: cannot evaluate foo() at compile time
Comment 1 Walter Bright 2010年04月01日 13:54:06 UTC
changeset 429
Comment 2 Don 2010年04月09日 19:20:38 UTC
Fixed DMD1.058 and DMD2.043.
Comment 3 Mike van Dongen 2012年11月09日 02:32:55 UTC
It seems that when I use an 2D AA this problem still occurs.
This is the code I used:
enum auto i = test();
int test()
{
 string[][string] s;
 s["a"] ~= "anything";
	
 return 6;
}
It gives me almost the same error (on Linux x64) the OP had:
Error: cannot index null array s
Comment 4 Don 2012年11月14日 01:38:11 UTC
(In reply to comment #3)
> It seems that when I use an 2D AA this problem still occurs.
Your test case is completely different to the original bug, it is a bug in ~=.
Please do not reopen ancient bugs. The *only* time you should open a bug which was listed as fixed in a previous changelog, is if you find that the test cases in bug weren't actually fixed in that release.
Moved to bug 9023.


AltStyle によって変換されたページ (->オリジナル) /