Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array slice initialization with implicitly castable type #9948

Open
dlangBugzillaToGithub opened this issue Jan 20, 2013 · 3 comments
Open

Comments

@dlangBugzillaToGithub
Copy link

bearophile_hugs reported this on 2013-01-20T15:36:26Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=9363

CC List

Description

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
@dlangBugzillaToGithub
Copy link
Author

andrej.mitrovich (@AndrejMitrovic) commented on 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.

@dlangBugzillaToGithub
Copy link
Author

andrej.mitrovich (@AndrejMitrovic) commented on 2013-01-21T07:36:32Z

(In reply to comment #1)
> wrapper

I mean wrapped.

@dlangBugzillaToGithub
Copy link
Author

bearophile_hugs commented on 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.

@LightBender LightBender removed the P3 label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants