https://issues.dlang.org/show_bug.cgi?id=16226

          Issue ID: 16226
           Summary: -dip25 doesn't work if the return type is not explicit
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nob...@puremagic.com
          Reporter: issues.dl...@jmdavisprog.com

This code results in an error with -dip25:


    void main() @safe
    {
        int i;
        foo(i);
    }

    ref int foo(ref int bar) @safe
    {
        return bar;
    }



but this code


    void main() @safe
    {
        int i;
        foo(i);
    }

    ref foo(ref int bar) @safe
    {
        return bar;
    }


and this code


    void main() @safe
    {
        int i;
        foo(i);
    }

    ref auto foo(ref int bar) @safe
    {
        return bar;
    }

do not result in an error. Note that unless the return type actually includes
int explictly rather than letting it be inferred, -dip25 is bypassed
completely. Interestingly enough, it does catch this case though and error out
correctly:

    void main() @safe
    {
        foo();
    }

    ref foo() @safe
    {
        int bar = 42;
        return bar;
    }

--

Reply via email to