Thread overview
[Issue 21518] delegates not checked for attribute match in const arrays
Jan 01, 2021
Dlang Bot
Jan 02, 2021
Dlang Bot
Jan 14, 2023
Iain Buclaw
January 01, 2021
https://issues.dlang.org/show_bug.cgi?id=21518

moonlightsentinel@disroot.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |moonlightsentinel@disroot.o
                   |                            |rg
            Summary|delegates not checked for   |delegates not checked for
                   |attribute match in const    |attribute match in const
                   |array parameters            |arrays

--- Comment #1 from moonlightsentinel@disroot.org ---
This issue is not restricted to function parameters:

void delegates()
{
    const dg = delegate() @system { int* p; int x; p = &x; };
    // pragma(msg, typeof(dg)); // const(void delegate() pure nothrow @nogc
@system)

    // No error
    const(void delegate() @safe)[] arg = [ dg ];
    // pragma(msg, typeof(arg)); // const(void delegate() @safe)[]

    // Correctly fails
    // void delegate() @safe[] arg = [ dg ];
}

--
January 01, 2021
https://issues.dlang.org/show_bug.cgi?id=21518

--- Comment #2 from moonlightsentinel@disroot.org ---
Also not restricted (In reply to moonlightsentinel from comment #1)
> This issue is not restricted to function parameters:
> 
> void delegates()
> {
>     const dg = delegate() @system { int* p; int x; p = &x; };
>     // pragma(msg, typeof(dg)); // const(void delegate() pure nothrow @nogc
> @system)
> 
>     // No error
>     const(void delegate() @safe)[] arg = [ dg ];
>     // pragma(msg, typeof(arg)); // const(void delegate() @safe)[]
> 
>     // Correctly fails
>     // void delegate() @safe[] arg = [ dg ];
> }

Also missing:

    const(void delegate() @system)[] sysA = [ dg ];
    const(void delegate() @safe)[] safeA = sysA;

--
January 01, 2021
https://issues.dlang.org/show_bug.cgi?id=21518

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
@MoonlightSentinel created dlang/dmd pull request #12090 "Fix 21518 - delegates not checked for attribute match in const arrays" fixing this issue:

- Fix 21518 - delegates not checked for attribute match in const arrays

  Const-conversion checks for delegates are forwarded to the type of
  `funcptr`. But `TypeFunction` did not implement `constConv`, causing
  the inherited `TypeNext.constConv` (which only checks const`/`shared`/...).
  to ignore the missmatched attributes.

  The bug was restricted to `const` arrays because checks for (im)mutable
  arrays didn't use `constConv` and instead failed due to the missmatched
  `deco`.

https://github.com/dlang/dmd/pull/12090

--
January 02, 2021
https://issues.dlang.org/show_bug.cgi?id=21518

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #12090 "Fix 21518 - delegates not checked for attribute match in const arrays" was merged into master:

- de27c4edb84cab50f93f77283702d32bc6a38b48 by MoonlightSentinel:
  Fix 21518 - delegates not checked for attribute match in const arrays

  Const-conversion checks for delegates are forwarded to the type of
  `funcptr`. But `TypeFunction` did not implement `constConv`, causing
  the inherited `TypeNext.constConv` (which only checks const`/`shared`/...).
  to ignore the missmatched attributes.

  The bug was restricted to `const` arrays because checks for (im)mutable
  arrays didn't use `constConv` and instead failed due to the missmatched
  `deco`.

https://github.com/dlang/dmd/pull/12090

--
January 14, 2023
https://issues.dlang.org/show_bug.cgi?id=21518

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=23626

--