www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22130] New: [REG2.080.1][DIP1000] pure factory functions

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

          Issue ID: 22130
           Summary: [REG2.080.1][DIP1000] pure factory functions stopped
                    working
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ag0aep6g gmail.com

Relevant forum thread:
https://forum.dlang.org/post/rkqepmhiizlzshhivblf forum.dlang.org
Needs `-preview=dip1000` (`-dip1000` in older compilers).
Fails since 2.080.1 according to run.dlang.io.

Should work because `f` is a "pure factory function" [1]:

----
int* f(const int* input) pure nothrow  safe
{
    int* output;
    return output;
}
void main() pure nothrow  safe
{
    int* c = new int;
    immutable int* i = f(c);
}
----

[1] https://dlang.org/spec/function.html#pure-functions

--
Jul 19