[Issue 10138] Regression (2.063 git-head): Using ReturnType with scoped no longer works
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon May 27 15:39:23 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10138
--- Comment #5 from Kenji Hara <k.hara.pg at gmail.com> 2013-05-27 15:39:22 PDT ---
(In reply to comment #4)
> Here's the thing, though. In that phobos pull, monarchdodra commented with:
>
> "Finally, I gave Scoped an @disabled this() to prevent our smarter users from
> trying to build a Scoped using typeof."
>
> It seems like he is actively trying to *disallow* using either ReturnType or
> typeof in order to create a scoped field variable.
>
> But, typeof still works. In 2.063 your example code will become:
[snip]
You are confusing about @disable for `Scoped` struct default construction and
calling `scoped` function with zero argument.
If new A() is valid, scoped!A() is also valid. The latter is corresponding to
the former. It's the design of scoped utility.
> So now I can't tell whether we *support* using scoped field variables or is the
> above just a hack? I need to know what to put in the changelog.
The rejected case from 2.063 is this:
class A
{
this() {}
this(int) {}
}
class B
{
typeof(scoped!A()) a;
this() // L12
{
//a = scoped!A();
//a = scoped!A(1);
}
}
Output:
test.d(12): Error: constructor test.B.this field a must be initialized in
constructor
The field B.a is must be initialized in constructor, comes from the @disable
this() defined in typeof(scoped!A()) struct.
However, getting the type of Scoped struct by using typeof is still allowed. So
typeof(scoped!A()) a;
is valid from 2.063.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list