digitalmars.D.bugs - [Issue 4886] New: Template (alias) tuple parameters cannot take .length property in compiletime
- d-bugmail puremagic.com (51/51) Sep 18 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4886
- d-bugmail puremagic.com (21/21) Sep 19 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4886
- d-bugmail puremagic.com (26/26) Sep 22 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4886
- d-bugmail puremagic.com (11/11) May 30 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4886
http://d.puremagic.com/issues/show_bug.cgi?id=4886 Summary: Template (alias) tuple parameters cannot take .length property in compiletime Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: zan77137 nifty.com This code doesn't work! ---- auto test(ARGS...)() { int[ARGS.length] x; return x; } void main(string[] args) { void func(){ } auto t = test!(func)(); } ---- Results: prog.d(3): Error: identifier 'length' of 'ARGS.length' is not defined prog.d(3): Error: index is not a type or an expression prog.d(10): Error: template instance prog.main.test!(func) error instantiating Workaround is this: ---- size_t lengthof(ARGS...)() { return ARGS.length; } auto test(ARGS...)() { int[lengthof!(ARGS)()] x; return x; } void main(string[] args) { void func(){ } auto t = test!(func)(); } ---- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 18 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4886 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cc Reduced test case: template Foo(T...) { int[T.length] x; } static assert(Foo!(1, 2, 3).x.length == 3); void main() {} A workaround: template Foo(T...) { int[cast(int)T.length] x; } static assert(Foo!(1, 2, 3).x.length == 3); void main() {} -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 19 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4886 --- Created an attachment (id=764) Patch against dmd r680, fixes resolveHelper() This patch fixes the reported issue and bug 2953 (D2). It passed dmd, druntime and phobos tests. The patch also fixes the following problems: -------------------- struct R { alias int T; } struct S { R r; alias r this; } S.T x; // (10) int[S.r.offsetof] y; // (11) -------------------- % dmd -o- -c test.d test.d(10): Error: S.T is used as a type test.d(11): Error: no property 'offsetof' for type 'R' -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 22 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4886 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED All of cases work in 2.060head. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 30 2012