www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23497] New: Erroneous escape reference to parameter error.

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

          Issue ID: 23497
           Summary: Erroneous escape reference to parameter error.
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: deadalnix gmail.com

Sample code:

class CompileError {}

CompileError errorize(Type t) {
        return t.error;
}

struct Type {
        CompileError _error;

        void kind() {}

         property
        auto error() in {
                kind();
        } do {
                return _error;
        }
}


Compiling this sample code fails with the following error: "Error: returning
`t.error()` escapes a reference to parameter `t`".

This used to compile in 2.100, but fails in 2.101 and as far as I can tell,
this is erroneous.

--
Nov 19 2022