www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8848] New: Array literals and AA literals are rejected as template value parameters

reply d-bugmail puremagic.com writes:
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



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: -------
Oct 18 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8848


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc




 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: -------
Oct 18 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8848






 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: -------
Oct 19 2012
prev sibling parent d-bugmail puremagic.com writes:
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



14:41:26 PDT ---



 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: -------
Aug 22 2013