Bug 9363 – Array slice initialization with implicitly castable type

Status
NEW
Severity
normal
Priority
P3
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-01-20T15:36:26Z
Last change time
2024-12-01T16:16:11Z
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: phobos#9948 →

Comments

Comment #0 by bearophile_hugs — 2013-01-20T15:36:26Z
This code works: import std.typecons: Typedef; alias Typedef!(int[]) MyArray; void main() { MyArray arr; arr.length = 10; arr[] = 0; } While this: import std.typecons: Typedef; alias Typedef!(ubyte[]) MyArray; void main() { MyArray arr; arr.length = 10; arr[] = 0; } Gives (dmd 2.062alpha): ...\dmd2\src\phobos\std\typecons.d(2811): Error: cannot implicitly convert expression (v) of type int to ubyte[] temp.d(6): Error: template instance std.typecons.Typedef!(ubyte[], null).Typedef.Proxy!(Typedef_payload).opSliceAssign!(Typedef!(ubyte[], null), int) error instantiating
Comment #1 by andrej.mitrovich — 2013-01-21T07:36:05Z
std.typecons.Proxy is really poorly designed. Essentially every possible operator is shoved in there without doing any sort of check on what is being wrapper (except for the one check for classes). Btw please don't use the Platform field unless it's a platform-specific bug, thanks.
Comment #2 by andrej.mitrovich — 2013-01-21T07:36:32Z
(In reply to comment #1) > wrapper I mean wrapped.
Comment #3 by bearophile_hugs — 2013-01-21T09:15:34Z
(In reply to comment #1) > Btw please don't use the Platform field unless it's a platform-specific bug, > thanks. The Platform tag was set to Windows because the error message that I have put here comes from Windows. It doesn't mean it's a Windows-only problem.
Comment #4 by robert.schadek — 2024-12-01T16:16:11Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9948 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB