www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1064] New: Compile time array literal from a tuple

reply d-bugmail puremagic.com writes:
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.


-- 
Mar 15 2007
parent d-bugmail puremagic.com writes:
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: -------
Oct 27 2010