Issue 15792 - Error Filling an array
Summary: Error Filling an array
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P3 minor
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-12 16:14 UTC by Alex
Modified: 2024-12-01 16:26 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Alex 2016-03-12 16:14:53 UTC
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);
Comment 1 Alex 2016-03-12 18:34:11 UTC
The error is: 
Error: cannot implicitly convert expression (1) of type int to Nullable!uint[]
Comment 2 Alex 2016-03-12 20:14:13 UTC
filling via 

arr[] = Nullable!uint(1); 

is also possible
Comment 3 RazvanN 2023-02-13 14:52:17 UTC
This is not a compiler bug, but at most a phobos one.
Comment 4 dlangBugzillaToGithub 2024-12-01 16:26:19 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/10166

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB