Bug 22130 – [REG2.080.1][DIP1000] pure factory functions stopped working

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-07-19T10:22:09Z
Last change time
2022-01-25T10:23:32Z
Keywords
pull, rejects-valid
Assigned to
No Owner
Creator
ag0aep6g
See also
https://issues.dlang.org/show_bug.cgi?id=17635, https://issues.dlang.org/show_bug.cgi?id=21660

Comments

Comment #0 by ag0aep6g — 2021-07-19T10:22:09Z
Relevant forum thread: https://forum.dlang.org/post/[email protected] 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
Comment #1 by dlang-bot — 2021-07-19T10:47:03Z
@aG0aep6G created dlang/dmd pull request #12890 "fix issues 22130, 17635 - pure factory functions" fixing this issue: - fix issues 22130, 17635 - pure factory functions Issue 22130 - [REG2.080.1][DIP1000] pure factory functions stopped working Issue 17635 - [REG 2.066.0] cannot convert unique immutable(int)** to immutable Immutable parameters are not needed for strong purity. Const is enough. Mutability in the return type is an additional condition on top of strong purity when considering side effects. The test case for issue 17635 was inverted without good reason in <https://github.com/dlang/dmd/pull/8048>. Flipping again to revert that mistake. https://github.com/dlang/dmd/pull/12890
Comment #2 by dlang-bot — 2022-01-25T10:23:32Z
dlang/dmd pull request #12890 "fix issues 22130, 17635 - pure factory functions" was merged into master: - 8e5fc75426076f6e83dea731bc3e9f4b0935de3e by aG0aep6G: fix issues 22130, 17635 - pure factory functions Issue 22130 - [REG2.080.1][DIP1000] pure factory functions stopped working Issue 17635 - [REG 2.066.0] cannot convert unique immutable(int)** to immutable Immutable parameters are not needed for strong purity. Const is enough. Mutability in the return type is an additional condition on top of strong purity when considering side effects. The test case for issue 17635 was inverted without good reason in <https://github.com/dlang/dmd/pull/8048>. Flipping again to revert that mistake. https://github.com/dlang/dmd/pull/12890