Bug 12031 – Possible dollar handling inconsistencies in std.typecons.Typedef array

Status
NEW
Severity
normal
Priority
P3
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-01-29T08:28:51Z
Last change time
2024-12-01T16:19:57Z
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: phobos#10028 →

Comments

Comment #0 by bearophile_hugs — 2014-01-29T08:28:51Z
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]
Comment #1 by peter.alexander.au — 2014-02-01T05:59:06Z
The first issue is a Phobos bug: it just doesn't forward opDollar. The second seems like a DMD bug.
Comment #2 by peter.alexander.au — 2014-02-01T12:28:36Z
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
Comment #3 by github-bugzilla — 2014-02-04T06:00:04Z
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
Comment #4 by bearophile_hugs — 2014-09-23T20:06:31Z
Now the error messages become: test.d(8,13): Error: cannot implicitly convert expression (a.opSlice(__dollar - 4u, __dollar)) of type ubyte[] to ubyte[4] test.d(12,13): Error: cannot implicitly convert expression (a.opSlice(21u, 25u)) of type ubyte[] to ubyte[4]
Comment #5 by b2.temp — 2023-02-11T05:16:34Z
This is not a compiler bug. The problem is that `std.typecons.TypeDef` uses an inner `std.typecons.Proxy` but as documented `Proxy` blocks implicit conversions. Now the big question is if it's an "invalid issue" (and maybe that "TypeDef" DDOC is incomplete then) or if "TypeDef" implementation is not correct.
Comment #6 by robert.schadek — 2024-12-01T16:19:57Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10028 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB