Thread overview
[Issue 23933] auto return type disables DIP1000 scope check
4 days ago
Atila Neves
4 days ago
RazvanN
4 days ago
RazvanN
4 days ago
RazvanN
4 days ago
https://issues.dlang.org/show_bug.cgi?id=23933

Atila Neves <atila.neves@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, safe

--
4 days ago
https://issues.dlang.org/show_bug.cgi?id=23933

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

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

--- Comment #1 from RazvanN <razvan.nitu1305@gmail.com> ---
Under the current specification this is not a bug, even though the behavior is surprising. Attributes are inferred for auto functions because you a function body needs to be present. Attributes are not inferred for non-auto functions, even if the body is present.

--
4 days ago
https://issues.dlang.org/show_bug.cgi?id=23933

--- Comment #2 from RazvanN <razvan.nitu1305@gmail.com> ---
[...] for auto functions because a function body needs to be present*

--
4 days ago
https://issues.dlang.org/show_bug.cgi?id=23933

--- Comment #3 from RazvanN <razvan.nitu1305@gmail.com> ---
So, if we enable attribute inference for all functions that have a body, this will be fixed as a consequence. Or, the workaround would be to manually annotate `hmm` as scope.

--
4 days ago
https://issues.dlang.org/show_bug.cgi?id=23933

Richard Cattermole <alphaglosined@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |alphaglosined@gmail.com
         Resolution|---                         |INVALID

--- Comment #4 from Richard Cattermole <alphaglosined@gmail.com> ---
The inference can be seen when you use auto instead of scope inside of safeUsage when you output the AST.

```d
struct Struct
{
        int* p;
        @safe void hmm(int i)
        {
        }
}
```

vs with scope & auto:

```d
struct Struct
{
        int* p;
        auto pure nothrow @nogc @safe void hmm(int i)
        {
        }
}
```

I don't see a bug here. This looks to be working correctly. A method that was not annotated with scope, used with scope, works when inference is turned on. So I'm closing.

--