D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4723 - Bugs with Associative Arrays .init: Integer Divide by Zero / incompatible types
Summary: Bugs with Associative Arrays .init: Integer Divide by Zero / incompatible types
Status: RESOLVED DUPLICATE of issue 6433
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL: http://hibari.2ch.net/test/read.cgi/t...
Keywords:
Depends on: 3962
Blocks:
  Show dependency treegraph
 
Reported: 2010-08-25 06:00 UTC by SHOO
Modified: 2011-08-04 02:18 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 SHOO 2010-08-25 06:00:00 UTC
This code doesn't work:

void main() {
	int[int] a = (int[int]).init;
	a[1] = 2;
}

This makes runtime error:

object.Error: Integer Divide by Zero 




And this:

void main() {
	int[int] a = (int[int]).init;
	a[1] = 2;
}

This makes compiletime error:
Error: incompatible types for ((a) == (AssociativeArray(null))): 'int[int]' and 'AssociativeArray!(int,int)'



These bug probably depends on this:
    http://d.puremagic.com/issues/show_bug.cgi?id=3962
Comment 1 SHOO 2010-08-25 06:06:48 UTC
Sorry, I missed.

Correctly for #2:
void main() {
	int[int] a;
	assert(a == a.init);
}

Error: incompatible types for ((a) == (AssociativeArray(null))): 'int[int]' and
'AssociativeArray!(int,int)'
Comment 2 Martin Nowak 2011-08-04 02:18:38 UTC

*** This issue has been marked as a duplicate of issue 6433 ***