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

Error Filling an array #10166

Open
dlangBugzillaToGithub opened this issue Mar 12, 2016 · 3 comments
Open

Error Filling an array #10166

dlangBugzillaToGithub opened this issue Mar 12, 2016 · 3 comments

Comments

@dlangBugzillaToGithub
Copy link

sascha.orlov reported this on 2016-03-12T16:14:53Z

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

CC List

  • razvan.nitu1305

Description

Didn't find an existing issue for this. Sorry, if missed.

As described here: 
https://forum.dlang.org/post/iizchhylkxistlnbijzd@forum.dlang.org

There is an error during an attempt to fill an array of Nullable!uint during the execution of

void main()
{
    import std.typecons;
    Nullable!uint[] arr;
    arr.length = 5;
    arr[] = 1;
}

The suggested workaround is, currently, using a cast:
arr[] = cast(Nullable!uint)1;

Also an option would be: 
import std.algorithm;
fill(arr, 1);
@dlangBugzillaToGithub
Copy link
Author

sascha.orlov commented on 2016-03-12T18:34:11Z

The error is: 
Error: cannot implicitly convert expression (1) of type int to Nullable!uint[]

@dlangBugzillaToGithub
Copy link
Author

sascha.orlov commented on 2016-03-12T20:14:13Z

filling via 

arr[] = Nullable!uint(1); 

is also possible

@dlangBugzillaToGithub
Copy link
Author

razvan.nitu1305 commented on 2023-02-13T14:52:17Z

This is not a compiler bug, but at most a phobos one.

@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