[Issue 3075] void delegate(const(void)[]) should be implicitly convertable to void delegate(void[])

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jul 3 07:56:22 PDT 2009


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


david <davidl at 126.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |




--- Comment #5 from david <davidl at 126.com>  2009-07-03 07:56:21 PDT ---
(In reply to comment #3)
> const, yes, but not immutable as that would require that mutable be implicitly
> convertible to immutable, which cannot be.

It's not implicit cast. But a special case for function/delegate parameters.

Any qualifier for parameters or for the function is a restriction for the
function. So you can still treat them as a special case of mutable version just
they don't change anything even they are allowed to change the parameter.


This is another testcase. 
void foo(void delegate(void[]) dg);

void test()
{
    void func(invariant(void)[] t)
    {
    }

    foo(&func);
}

test.func won't change paramter t. So this func as a delegate is perfectly safe
to hold the prototype which has no restrictions on parameters.

It's not casting invariant(void)[] to void[]. It's implicitly casting from
"void delegate(invariant(void)[])" to "void delegate(void[])".

Furthermore, it's pretty ugly to write:
void foo(void delegate(void[]) dg);

void test()
{
    void func(invariant(void)[] t)
    {
    }

    foo(cast(void delegate(void[]))&func);
}

I don't think it is an invalid bug. But you can mark it as WONTFIX.

-- 
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