http://d.puremagic.com/issues/show_bug.cgi?id=7355



--- Comment #5 from Steven Schveighoffer <schvei...@yahoo.com> 2012-01-26 
09:36:01 PST ---
(In reply to comment #3)

> The typeof resolves to error because inout resolves to immutable.

As I said, it should fail to match or match mutable and fail to call.  I'm not
sure which is correct, but I feel either way that the assert should fail.  If
it's resolving to immutable, I think it's a bug, not because it's not passing,
but because it's failing for the wrong reason.

I think your expectations would be a violation of const.  Let's assume inout
did resolve to const for foo, and the function could be called:

immutable int x = 5;
immutable(int)* xp = &x;
immutable(int)** xpp = &xp;

const(int *)* y = foo(xpp);

int z = 2;

*y = &z; // this should pass, since I can assign int* to const(int*).

assert(*xp == 2);
z = 3;
assert(*xp == 3); // oops!  changed data perceived as immutable!

Is there an error in my example?  I think it comes down to this:

immutable(int *)* foo(immutable(int *)* x) // inout == immutable
    const(int *)* foo(    const(int *)* x) // inout == const
          int **  foo(          int **  x) // inout == mutable

none of these can be called with immutable(int)** because there is no implicit
cast to the parameter.  I don't think const(immutable(int)*)* reduces to
const(int *)*.

This does take some mental effort, so I may have made a mistake :)  I hate
double pointers...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to