www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 525] New: can't use array variable in tuple index

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=525

           Summary: can't use array variable in tuple index
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: lovesyao hotmail.com


import std.typetuple;
const int[] test=[1];
alias TypeTuple!(ulong,uint,ushort,ubyte) tuple;
static assert(is(tuple[1]==uint));//ok
static assert(is(tuple[test[0]]==uint));//failed

Output:
tuple_bug.d(5): static assert  (is((ulong, uint, ushort, ubyte)[void[0]] ==
uint)) is false


-- 
Nov 15 2006
next sibling parent Don Clugston <dac nospam.com.au> writes:
d-bugmail puremagic.com wrote:
 http://d.puremagic.com/issues/show_bug.cgi?id=525
 
            Summary: can't use array variable in tuple index
            Product: D
            Version: unspecified
           Platform: All
         OS/Version: All
             Status: NEW
           Severity: normal
           Priority: P2
          Component: DMD
         AssignedTo: bugzilla digitalmars.com
         ReportedBy: lovesyao hotmail.com
 
 
 import std.typetuple;
 const int[] test=[1];
 alias TypeTuple!(ulong,uint,ushort,ubyte) tuple;
 static assert(is(tuple[1]==uint));//ok
 static assert(is(tuple[test[0]]==uint));//failed
 
 Output:
 tuple_bug.d(5): static assert  (is((ulong, uint, ushort, ubyte)[void[0]] ==
 uint)) is false
 
 

A simpler example: --------- const int a[] = [1,2,3]; const int b = a[2]; --------- Error: non-constant expression (a)[2]
Nov 16 2006
prev sibling next sibling parent reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=525





------- Comment #2 from lovesyao hotmail.com  2006-11-16 17:40 -------
I dont think so. I update example.

import std.typetuple;
const char[] a="\x01";
const char b=a[0];//ok
const char[] c="test";
static assert(c[a[0]]=='e');//ok
alias TypeTuple!(ulong,uint,ushort,ubyte) tuple;
static assert(is(tuple[1]==uint));//ok
static assert(is(tuple[a[0]]==uint));//failed


-- 
Nov 16 2006
parent Don Clugston <dac nospam.com.au> writes:
d-bugmail puremagic.com wrote:
 http://d.puremagic.com/issues/show_bug.cgi?id=525
 
 
 
 
 
 ------- Comment #2 from lovesyao hotmail.com  2006-11-16 17:40 -------
 I dont think so. I update example.
 
 import std.typetuple;
 const char[] a="\x01";
 const char b=a[0];//ok
 const char[] c="test";
 static assert(c[a[0]]=='e');//ok
 alias TypeTuple!(ulong,uint,ushort,ubyte) tuple;
 static assert(is(tuple[1]==uint));//ok
 static assert(is(tuple[a[0]]==uint));//failed

Interesting. Does it work with static assert(is(tuple[b]==uint)); ?
Nov 17 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=525





------- Comment #4 from lovesyao hotmail.com  2006-11-17 20:20 -------
it does.


-- 
Nov 17 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=525


bugzilla digitalmars.com changed:

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




------- Comment #5 from bugzilla digitalmars.com  2006-11-25 04:04 -------
Fixed DMD 0.175


-- 
Nov 25 2006