Thread overview
[Issue 12031] New: Possible dollar handling inconsistencies in std.typecons.Typedef array
Feb 01, 2014
Peter Alexander
Feb 01, 2014
Peter Alexander
January 29, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12031

           Summary: Possible dollar handling inconsistencies in
                    std.typecons.Typedef array
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2014-01-29 08:28:51 PST ---
I am not sure, but perhaps this code shows some inconsistencies:


import std.typecons: Typedef;
ubyte[4] foo1() {
    ubyte[25] a;
    return a[$ - 4 .. $]; // OK
}
ubyte[4] foo2() {
    Typedef!(ubyte[25]) a;
    return a[$ - 4 .. $]; // Error
}
ubyte[4] foo3() {
    Typedef!(ubyte[25]) a;
    return a[a.length - 4 .. a.length]; // Error
}
ubyte[4] foo4() {
    Typedef!(ubyte[25]) a;
    typeof(return) result;
    result[] = a[a.length - 4 .. a.length]; // OK
    return result;
}
void main() {}


dmd 2.065beta gives:

test.d(8): Error: undefined identifier __dollar
test.d(8): Error: undefined identifier __dollar
test.d(12): Error: cannot implicitly convert expression (a.opSlice(21u, 25u))
of type ubyte[] to ubyte[4]

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 01, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12031


Peter Alexander <peter.alexander.au@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |peter.alexander.au@gmail.co
                   |                            |m


--- Comment #1 from Peter Alexander <peter.alexander.au@gmail.com> 2014-02-01 05:59:06 PST ---
The first issue is a Phobos bug: it just doesn't forward opDollar.

The second seems like a DMD bug.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 01, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12031


Peter Alexander <peter.alexander.au@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|Phobos                      |DMD


--- Comment #2 from Peter Alexander <peter.alexander.au@gmail.com> 2014-02-01 12:28:36 PST ---
I've submitted a pull for the opDollar issue, so I'm going to change this to a DMD bug so that those folks can take a look at the other issue.

https://github.com/D-Programming-Language/phobos/pull/1899

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 04, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12031



--- Comment #3 from github-bugzilla@puremagic.com 2014-02-04 06:00:04 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/27a6d57972ea14e0bd9383d1b9f9450cecce2107 Fix Issue 12031 (partial) - opDollar for Typedef!T

Just forwarding the various kinds of `opDollar` in `Proxy!T`. Partially fixes bug 12031 -- I believe a dmd change is needed to completely fix it (separate to opDollar forwarding).

https://github.com/D-Programming-Language/phobos/commit/ae9356537e8511dd6074207d4649c2c93f3d83c5 Merge pull request #1899 from Poita/bug12031

Fix Issue 12031 (partial) - opDollar for Typedef!T

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------