Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/func.d
Original file line number Diff line number Diff line change
Expand Up @@ -2238,6 +2238,13 @@ extern (C++) class FuncDeclaration : Declaration
}
}

if (vthis && vthis.storage_class & STCmaybescope)
{
vthis.storage_class &= ~STCmaybescope;
vthis.storage_class |= STCscope;
f.isscope = true;
}

// reset deco to apply inference result to mangled name
if (f != type)
f.deco = null;
Expand Down Expand Up @@ -2402,6 +2409,8 @@ extern (C++) class FuncDeclaration : Declaration
if (tf.isscope)
v.storage_class |= STCscope;
}
if (flags & FUNCFLAGinferScope)
v.storage_class |= STCmaybescope;

v.semantic(sc);
if (!sc.insert(v))
Expand Down
23 changes: 23 additions & 0 deletions test/fail_compilation/retscope.d
Original file line number Diff line number Diff line change
Expand Up @@ -589,3 +589,26 @@ void foo18()
typeof(&c.funcrs) fs4 = &c.funcrs;
}

/********************************************/


bool foo20(const string a) @safe pure nothrow @nogc
{
return !a.length;
}

struct Result(R)
{
R source;

bool empty() // infer 'scope' for 'this'
{ return foo20(source); }
}

@safe void test20()
{
scope n = Result!string("abc");
n.empty();
}