On Thu, 31 Dec 2009 16:20:08 -0500, Walter Bright
<newshou...@digitalmars.com> wrote:
Steven Schveighoffer wrote:
(I'm assuming bug 1961('scoped const') is considered to be fixed).
Sadly, it's not fixed yet :(
struct S
{
int x;
inout(int)* getX() inout { return &x;}
}
void main()
{
S s;
int *x = s.getX();
}
testinout.d(10): Error: function testinout.S.getX () inout is not
callable using argument types ()
testinout.d(10): Error: cannot implicitly convert expression (s.getX())
of type inout(int)* to int*
It appears the auto-conversion is not happening on the return, and
also the call isn't working.
The inout on the return has to be at the top level, as in inout(int *).
This probably needs improvement.
Yes, this is an important distinction.
With your recommended change, the error is now:
testinout.d(4): Error: inout on return means inout must be on a parameter
as well for inout inout(int*)()
inout doesn't seem to work with ref either. The only thing I could get to
work is this:
struct S
{
int x;
}
inout(int *) getSX(inout S* s) { return &s.x;}
void main()
{
S s;
const(S)* sp = &s;
int *x = getSX(&s);
//int *y = getSX(sp); // uncomment this line for an error
const(int) *y = getSX(sp);
}
If you uncomment the designated line, the error reads:
testinout.d(13): Error: cannot implicitly convert expression (getSX(sp))
of type const(int*) to int*
which looks good.
-Steve