Thread overview
[Issue 1064] New: Compile time array literal from a tuple
Mar 15, 2007
d-bugmail
Oct 27, 2010
Shin Fujishiro
[Issue 1064] Tuples are not expanded in array initializers
Feb 03, 2012
yebblies
Jul 21, 2012
Kenji Hara
Jul 21, 2012
Kenji Hara
March 15, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1064

           Summary: Compile time array literal from a tuple
           Product: D
           Version: 1.009
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: jmjmak@utu.fi


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.


-- 

October 27, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1064


Shin Fujishiro <rsinfu@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au


--- Comment #1 from Shin Fujishiro <rsinfu@gmail.com> 2010-10-27 15:23:45 PDT ---
*** Issue 3263 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 03, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=1064


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #2 from yebblies <yebblies@gmail.com> 2012-02-03 21:06:08 EST ---
https://github.com/D-Programming-Language/dmd/pull/690

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 21, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=1064



--- Comment #3 from github-bugzilla@puremagic.com 2012-07-20 21:52:54 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 21, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=1064



--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2012-07-20 23:35:18 PDT ---
Fixed for D1: https://github.com/9rnsr/dmd/commit/55bedf48b0df58c7c4e4aeb4c8ed9969bfab1005

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 21, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=1064


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------