[Issue 21583] New: `array` is not `@safe` for a certain combination of `iota` and data types
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jan 26 05:42:04 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=21583
Issue ID: 21583
Summary: `array` is not `@safe` for a certain combination of
`iota` and data types
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: industry, safe
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: pro.mathias.lang at gmail.com
I'm fairly certain the following should compile:
```
import std.range, std.array, std.algorithm;
@safe:
struct Block { int[] data; }
public struct Height
{
///
public ulong value;
/// Provides implicit conversion to `ulong`
public alias value this;
}
void main () @safe
{
auto x = getBlocksFrom(Height.init);
}
public auto getBlocksFrom (Height start_height) @safe nothrow
{
auto r = iota(start_height, Height(42));
auto r2 = r.map!(idx => const(Block).init);
return r2.array;
}
```
Bug disappear if:
- The mapping is not to a `const(Block)`;
- I pass `ulong` or similar instead of `Height`;
- `Block` does not contain an array... Or if it's a `string`;
--
More information about the Digitalmars-d-bugs
mailing list