← Back to index
|
Original Bugzilla link
Bug 525 – can't use array variable in typetuple index
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2006-11-15T21:07:00Z
Last change time
2015-06-09T05:14:49Z
Assigned to
bugzilla
Creator
lovesyao
Comments
Comment #0
by lovesyao — 2006-11-15T21:07:08Z
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
Comment #1
by aldacron — 2006-11-16T08:25:30Z
[email protected]
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:
[email protected]
> ReportedBy:
[email protected]
> > > 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 > > This is because there's no constant folding of array indexes and slices. A simpler example: --------- const int a[] = [1,2,3]; const int b = a[2]; --------- Error: non-constant expression (a)[2]
Comment #2
by lovesyao — 2006-11-16T17:40:38Z
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
Comment #3
by aldacron — 2006-11-17T08:55:23Z
[email protected]
wrote: >
http://d.puremagic.com/issues/show_bug.cgi?id=525
> > > > > > ------- Comment #2 from
[email protected]
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)); ?
Comment #4
by lovesyao — 2006-11-17T20:20:16Z
it does.
Comment #5
by bugzilla — 2006-11-25T04:04:16Z
Fixed DMD 0.175