Bug 2953 – tuple.length rejected as a tuple parameter in a static foreach

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2009-05-08T03:41:00Z
Last change time
2014-04-18T09:12:08Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2009-05-08T03:41:22Z
This bug was created from Bug 2687. Workaround (D2), change the foreach to enum args_length = args.length; foreach( x ; Range!(args_length) ){ } --- template Tuple(T...){ alias T Tuple; } template Range(int b){ alias Tuple!(1) Range; } void foo()(){ Tuple!(int, int) args; foreach( x ; Range!(args.length) ){ } } void main(){ foo!()(); } --- ice.d(411): Error: identifier 'length' of 'args.length' is not defined ice.d(411): Error: template instance Range!(int) does not match template declara tion Range(int b) ice.d(411): Error: foreach: void is not an aggregate type ice.d(416): Error: template instance ice.foo!() error instantiating
Comment #1 by ellery-newcomer — 2011-08-11T18:51:10Z
Ran into something similar a while back, but I don't think foreach has anything to do with it: template Sequenced(){ template Inner(ThisNode, Value, size_t N){ } } struct IndexedBy(L...) { alias L List; } class MIC(IndexedBy){ alias int ThisNode; void _RemoveAllBut(size_t N)(ThisNode* node){ } /// disattach node from all indeces. alias _RemoveAllBut!(IndexedBy.List.length) _RemoveAll; } void main(){ alias MIC!(IndexedBy!(Sequenced!())) C; } yields 1 error message: Error: identifier 'length' of 'IndexedBy.List.length' is not defined
Comment #2 by clugdbug — 2011-08-11T22:40:45Z
Reduced form of the test case in comment 1: --------- template Sequenced() {} struct IndexedBy(L...) { alias L List; } struct MIC(F){ int[F.List.length] w; } alias MIC!( IndexedBy!(Sequenced!()) ) C; ---------- test3.d(14): Error: identifier 'length' of 'F.List.length' is not defined test3.d(17): Error: template instance test3.MIC!(IndexedBy!(__T9SequencedZ)) err or instantiating Looks like a failure to resolve aliases, for a template which is a member of a tuple.
Comment #3 by k.hara.pg — 2011-09-22T11:41:19Z
Comment #4 by bugzilla — 2011-09-22T15:01:39Z