dip1000, perhaps annotate with return, and vibe-d

aliak something at something.com
Wed Jul 24 12:54:51 UTC 2019


Trying to get dip1000 flag in use. I have this error:

Error: returning Optional(null, false).this(value) escapes a 
reference to parameter value, perhaps annotate with return

in this function:

public auto some(T)(auto ref T value) {
     return Optional!T(value); // <-- error on this line
}

And it's instantiated from here:

static Optional!T fromRepresentation(Json value) {
   if (value == Json.undefined) {
     return no!T;
   }
   return some(deserializeJson!T(value)); // <-- instantiated from 
here
}

I put the qualifier "return" on the parameter to some, but did 
nothing. And I put it on Optional.this() as well, but I'm not 
sure where I'm supposed to put it.

The constructor for Optional takes an auto ref T ... I'm not sure 
that makes sense. Does it make sense to take a constructor 
parameter that is copied in to the struct by auto ref if you're 
not calling .move on it explicitly?

And as for vibe-d, I get this when compiling with dip1000:

Also, vibe-d gives me this: 
../../../.dub/packages/vibe-core-1.6.2/vibe-core/source/vibe/internal/traits.d(391,2): Error: static assert:  "FileStream does not implement method "read" of type @safe ulong(scope ubyte[] dst, IOMode mode)"

Has anyone seen that or used vibed with dip1000?


More information about the Digitalmars-d-learn mailing list