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

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2953 - tuple.length rejected as a tuple parameter in a static foreach
Summary: tuple.length rejected as a tuple parameter in a static foreach
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
Depends on:
Blocks:
Reported: 2009年05月08日 03:41 UTC by Don
Modified: 2014年04月18日 09:12 UTC (History)
2 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Don 2009年05月08日 03:41:22 UTC
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 Ellery Newcomer 2011年08月11日 18:51:10 UTC
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 Don 2011年08月11日 22:40:45 UTC
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 Kenji Hara 2011年09月22日 11:41:19 UTC
https://github.com/D-Programming-Language/dmd/pull/407 


AltStyle によって変換されたページ (->オリジナル) /