[Issue 1379] New: Compiler doesn't allow associative array initializers.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jul 26 08:01:18 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1379
Summary: Compiler doesn't allow associative array initializers.
Product: D
Version: 1.019
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: aziz.kerim at gmail.com
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]
--
More information about the Digitalmars-d-bugs
mailing list