Thread overview | ||||||
---|---|---|---|---|---|---|
|
October 18, 2012 [Issue 8848] New: Array literals and AA literals are rejected as template value parameters | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=8848 Summary: Array literals and AA literals are rejected as template value parameters Product: D Version: D1 & D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: clugdbug@yahoo.com.au --- Comment #0 from Don <clugdbug@yahoo.com.au> 2012-10-18 02:41:18 PDT --- The template spec says that they are valid (both D1 and D2), but template Bleherg(int[int] X) {} gives: bug.d(1): Error: arithmetic/string type expected for value-parameter, not int[int] --- However, the compiler accepts them as template value parameters when used with in a tuple argument. The example below works correctly with both D1 and D2. ----- class C ( T ... ) { pragma(msg, "The keys are ", T[0].keys); pragma(msg, "The values are ", T[0].values); } alias C!( [ "abc"[] : 73, "sdg":6 ] ) G1; alias C!( [ 22354.56 : 273, 43565.12:96 ] ) G2; ----- Additionally, the name mangling for both array literals and AA literals is clearly documented in the spec ABI page. The error message is erroneous. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 18, 2012 [Issue 8848] Array literals and AA literals are rejected as template value parameters | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don | http://d.puremagic.com/issues/show_bug.cgi?id=8848 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs@eml.cc --- Comment #1 from bearophile_hugs@eml.cc 2012-10-18 02:56:16 PDT --- (In reply to comment #0) > The template spec says that they are valid (both D1 and D2), So are associative arrays accepted, but simple arrays aren't? template Foo(int[] X) {} template Bar(int[5] X) {} void main() {} ==> test.d(1): Error: arithmetic/string type expected for value-parameter, not int[] test.d(2): Error: arithmetic/string type expected for value-parameter, not int[5u] -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 19, 2012 [Issue 8848] Array literals and AA literals are rejected as template value parameters | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don | http://d.puremagic.com/issues/show_bug.cgi?id=8848 --- Comment #2 from Don <clugdbug@yahoo.com.au> 2012-10-19 02:40:26 PDT --- (In reply to comment #1) > (In reply to comment #0) > > The template spec says that they are valid (both D1 and D2), > > So are associative arrays accepted, but simple arrays aren't? > > template Foo(int[] X) {} > template Bar(int[5] X) {} > void main() {} No, the current DMD accepts neither arrays or AAs in declarations. But both can be passed in template tuple parameters. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 22, 2013 [Issue 8848] Array literals and AA literals are rejected as template value parameters | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don | http://d.puremagic.com/issues/show_bug.cgi?id=8848 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich@gmail.com --- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-08-22 14:41:26 PDT --- (In reply to comment #2) > (In reply to comment #1) > > (In reply to comment #0) > > > The template spec says that they are valid (both D1 and D2), > > > > So are associative arrays accepted, but simple arrays aren't? > > > > template Foo(int[] X) {} > > template Bar(int[5] X) {} > > void main() {} > > No, the current DMD accepts neither arrays or AAs in declarations. But both can be passed in template tuple parameters. W.r.t. arrays, is this just a parser issue? It's odd that we have this situation: ----- // template Foo(ubyte[]) { } // nogo template Bar(T...) { } // ok void main() { enum ubyte[] x = [1, 2]; // alias y = Foo!(x); alias z = Bar!(x); // ok } ----- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation