[Issue 17512] New: [REG 2.073] wrong deduction of "return" function attribute

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Jun 15 14:46:21 PDT 2017


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

          Issue ID: 17512
           Summary: [REG 2.073] wrong deduction of "return" function
                    attribute
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: johanengelen at weka.io

Testcase:
```
struct A(T)
{
    T _value;

    bool _hasValue;

    auto ref getOr(T alternativeValue)
    {
        return _hasValue ? _value : alternativeValue;
    }
}

A!int a;
```

DMD 2.073 fails with:
> dmd -c testcase.d -o-
testcase.d(7): Error: function has 'return' but does not return any
indirections
testcase.d(13): Error: template instance testcase.A!int error instantiating

DMD 2.074:
> dmd -c testcase.d -o-
testcase.d(7): Error: function type 'pure nothrow @nogc return @safe int(int
alternativeValue)' has 'return' but does not return any indirections
testcase.d(13): Error: template instance manhole.A!int error instantiating


DMD 2.072.2 compiles it fine.

--


More information about the Digitalmars-d-bugs mailing list