Bug 2017 – Dynamic array creation

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2008-04-20T08:01:00Z
Last change time
2015-06-09T01:14:36Z
Keywords
rejects-valid, spec
Assigned to
nobody
Creator
gide

Comments

Comment #0 by gide — 2008-04-20T08:01:41Z
To create a dynamic arrays the following first example is ok, but the second fails, maybe the second method should compile? Also, the documentation does not mention the "abc"[] method to create a dynamic array. Example ------- auto str1 = "abc"[]; // OK auto str2 = ['a', 'b', 'c'][]; // Error, invalid syntax?
Comment #1 by gide — 2008-10-25T05:48:38Z
The following example now compiles in DMD v2.020, but it wasn't mentioned in the changelog, but the docs don't mention "abc"[] as a method of creating dynamic arrays. test.d ------ import std.stdio; void main() { auto str1 = "abc"[]; // OK auto str2 = ['a', 'b', 'c'][]; writefln(typeof(str1).stringof); writefln(typeof(str2).stringof); } Output ------ invariant(char)[] char[]
Comment #2 by yebblies — 2011-06-10T05:40:00Z
This now works as array literals are dynamic arrays.