D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1379 - Compiler doesn't allow associative array initializers.
Summary: Compiler doesn't allow associative array initializers.
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Linux
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2007-07-26 10:01 UTC by Aziz Köksal
Modified: 2014-02-16 15:21 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 Aziz Köksal 2007-07-26 10:01:17 UTC
auto foo = [1:1];

Getting the following errors for the above statement:

Error: cannot infer type from this array initializer
Error: array initializers as expressions are not allowed
Error: cannot use array to initialize int
Error: array initializers as expressions are not allowed
variable foo is not a static and cannot have static initializer

A nice workaround would be:

auto foo = ([1:1]); // Works only in function bodies. Otherwise getting:  Error: non-constant expression [1:1]
Comment 1 Haruki Shigemori 2010-08-25 05:43:07 UTC
As dmd 2.048, this issue is already fixed.