Thread overview
[Issue 20786] do attribute inference for all nested functions
May 05, 2020
RazvanN
May 05, 2020
RazvanN
[Issue 20786] do attribute inference for member functions inside nested aggregates
Dec 17, 2022
Iain Buclaw
April 29, 2020
https://issues.dlang.org/show_bug.cgi?id=20786

Steven Schveighoffer <schveiguy@yahoo.com> changed:

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

--
May 05, 2020
https://issues.dlang.org/show_bug.cgi?id=20786

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com

--- Comment #1 from RazvanN <razvan.nitu1305@gmail.com> ---
One problem with this request is that a lot of code will fail. I just tried implementing this locally and there are a lot of cases in druntime where nested functions with no attributes are declared and used as arguments to functions that receive an attribute-less function as parameter. Imposing attributes on functions where you don't actually care about them is annoying IMHO.

--
May 05, 2020
https://issues.dlang.org/show_bug.cgi?id=20786

--- Comment #2 from Steven Schveighoffer <schveiguy@yahoo.com> ---
Shouldn't that work though?

This compiles just fine:

void x(void function() foo) { foo(); }

void bar() @nogc pure nothrow @safe {}

void main()
{
    x(&bar);
}

I guess a good counter case would be helpful here.

--
May 05, 2020
https://issues.dlang.org/show_bug.cgi?id=20786

--- Comment #3 from RazvanN <razvan.nitu1305@gmail.com> ---
(In reply to Steven Schveighoffer from comment #2)
> Shouldn't that work though?
> 
> This compiles just fine:
> 
> void x(void function() foo) { foo(); }
> 
> void bar() @nogc pure nothrow @safe {}
> 
> void main()
> {
>     x(&bar);
> }
> 
> I guess a good counter case would be helpful here.

Argh, you are right. I messed up the patch, sorry! It seems dmd does attribute inference for nested functions, except if the the function is the member of a nested aggregate declaration.

--
May 05, 2020
https://issues.dlang.org/show_bug.cgi?id=20786

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|do attribute inference for  |do attribute inference for
                   |all nested functions        |member functions inside
                   |                            |nested aggregates

--- Comment #4 from Steven Schveighoffer <schveiguy@yahoo.com> ---
(In reply to RazvanN from comment #3)
> It seems dmd does
> attribute inference for nested functions, except if the the function is the
> member of a nested aggregate declaration.

Oh interesting! I just tested that and you are right, I just assumed it would all be the same. Changing the title appropriately.

It's curious that nested member functions are not inferred (except inside @safe functions) when straight nested functions are.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=20786

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--
December 13
https://issues.dlang.org/show_bug.cgi?id=20786

--- Comment #5 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19698

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--