Weird DIP1000 issue
ag0aep6g
anonymous at example.com
Wed Feb 8 13:00:35 UTC 2023
On 08.02.23 00:42, 0xEAB wrote:
> ```d
> void main() @safe {
> auto mb = MBuf();
> auto vr = VRes!X();
> foreach(c; vr.errors)
> mb.write(c);
> }
>
> struct X { }
>
> struct MBuf {
> const(ubyte)[] _bufferList;
> void write(Buffers...)(Buffers buffers) {
> foreach (buffer; buffers) { }
> }
> }
>
> struct VErr { string m; }
>
> struct VRes(Data) {
> VErr[Data.tupleof.length] _errors;
> auto errors() {
> import std.algorithm;
> return _errors[].filter!(e => e.m);
> }
> }
> ```
[...]
> While I’m by no means sure that this is a bug, I would really hope for
> it to be one.
Here's a further reduction of one aspect of your snippet that looks like
a bug to me:
----
alias VErr = char*;
ref front_r(ref VErr r) { return r; }
ref front_p(VErr* p) { return *p; }
ref front_s(VErr[] s) { return s[0]; }
VErr g;
void main() @safe
{
VErr[1] _errors;
g = _errors[0]; /* copy from static array: ok */
g = front_r(_errors[0]); /* copy from `ref` via `ref`: ok */
g = front_p(&_errors[0]); /* copy from `ref` via pointer:
fails, should work */
g = front_s(_errors[]); /* copy from `ref` via slice:
fails, should work */
}
----
More information about the Digitalmars-d
mailing list