Bug 1064 – Tuples are not expanded in array initializers

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2007-03-15T14:36:00Z
Last change time
2015-06-09T05:10:44Z
Keywords
pull, rejects-valid
Assigned to
yebblies
Creator
onlystupidspamhere

Comments

Comment #0 by onlystupidspamhere — 2007-03-15T14:36:52Z
template T(E...) { alias E T; } // Error: cannot implicitly convert expression (tuple(1,2)) // of type (int, int) to int //int[] a = [ T!(1,2) ]; // Error: cannot implicitly convert expression (tuple(1)) // of type (int) to int //int[] a = [ T!(1) ]; struct S { // Error: cannot implicitly convert expression (tuple(1,2)) // of type (int, int) to int //static int[] a = [ T!(1,2) ]; // works static int[] a = [ 1,2 ]; } // works int[] a = [ 1,2 ]; void main() { // works int[] a = [ T!(1,2) ]; // works int[] b = [ T!(1) ]; // Error: cannot implicitly convert expression ([1,2]) // of type int[2] to int //auto c = [ T!(1,2) ]; // Error: tuple index 1 exceeds 1 // Error: cannot implicitly convert expression ([1]) // of type int[1] to int //auto d = [ T!(1) ]; } I suppose they all should work. It's possible to do (on the global scope) //int[] a = [ T!(1,2)[0], T!(1,2)[1] ]; but an arbitrary length tuple does not compile.
Comment #1 by rsinfu — 2010-10-27T15:23:45Z
*** Issue 3263 has been marked as a duplicate of this issue. ***
Comment #2 by yebblies — 2012-02-03T02:06:08Z
Comment #3 by github-bugzilla — 2012-07-20T21:52:54Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/0e6f6211aef226d913a3c29f3ff3f11a420cdf41 Issue 1064 - Tuples are not expanded in array initializers Expand any tuples in place. expandTuples from expression.c cannot be used because this is an array of ExpInitializers, not Expressions. https://github.com/D-Programming-Language/dmd/commit/162cf303c5e70bbb7b0a397b847e0b76c923ddd9 Merge pull request #690 from yebblies/issue1064 Issue 1064 - Tuples are not expanded in array initializers
Comment #4 by k.hara.pg — 2012-07-20T23:35:18Z