cat > bug.d << CODE
module bug;
struct File
{
@safe @nogc:
~this() scope
{
}
void* f;
}
void test() @safe @nogc
{
scope File f;
f = File();
}
CODE
dmd -c -dip1000 bug
----
bug.d(16): Error: scope variable f assigned to non-scope parameter this calling bug.File.opAssign
----
We should infer scope for any auto-generated functions like opAssign.
Comment #1 by bugzilla — 2018-03-12T02:41:31Z
Attributes are inferred for the generated opAssign, the result looks like:
@nogc ref return @trusted File opAssign(File p)
Not sure why scope is not inferred.
In any case, the example has problems as well:
scope File f;
f = File();
The lifetime of File() is less than that of f, so this example should fail to compile for that reason. https://issues.dlang.org/show_bug.cgi?id=17977 addresses that.