Comment #0 by razvan.nitu1305 — 2021-04-22T13:21:54Z
struct Strukt2 {
this(int* _block) { }
}
struct Strukt {
int* block;
Strukt2 foo() { return Strukt2(null); }
alias foo this;
}
import std.exception : doesPointTo;
bool wrapper(T)(ref T a, ref T b)
{
return doesPointTo(a, b);
}
void johan() pure {
Strukt a;
Strukt b;
assert(wrapper(a, b)); // error wrapper is not pure
//assert(doesPointTo(a, b)); // fine
}
doesPointTo [1] is specifically marked as being pure. I tried copy-pasting the code of doesPointTo into the same file with the wrapper declaration and that seems to fix the issue, so I assume it has something to do with where the code is emitted?
This is causing problems in phobos [2] because moveEmplaceImpl's purity is wrongfully affected by this [3].
[1] https://github.com/dlang/phobos/blob/master/std/exception.d#L1039
[2] https://issues.dlang.org/show_bug.cgi?id=21202
[3] https://github.com/dlang/phobos/blob/master/std/algorithm/mutation.d#L1414
Comment #1 by razvan.nitu1305 — 2021-04-22T13:23:22Z
If the wrapper is annotated with `pure`, code works fine.
Comment #2 by razvan.nitu1305 — 2021-08-17T16:35:24Z
*** Issue 21202 has been marked as a duplicate of this issue. ***
Comment #3 by dlang-bot — 2021-10-07T10:50:43Z
@BorisCarvajal created dlang/dmd pull request #13137 "Fix Issue 21850 - [REG2.093] Template inference of pure not working" fixing this issue:
- Fix Issue 21850 - [REG2.093] Template inference of pure not working
https://github.com/dlang/dmd/pull/13137
Comment #4 by dlang-bot — 2021-10-07T22:12:29Z
dlang/dmd pull request #13137 "Fix Issue 21850 - [REG2.093] Template inference of pure not working" was merged into stable:
- 9c45f71a0e15b60bae9389b3b3bd3611ddc61519 by Boris Carvajal:
Fix Issue 21850 - [REG2.093] Template inference of pure not working
https://github.com/dlang/dmd/pull/13137
Comment #5 by dlang-bot — 2021-10-10T23:13:21Z
dlang/dmd pull request #13149 "merge stable" was merged into master:
- 276dd52c51338bde2f0d1b4898c4211971d2f818 by Boris Carvajal:
Fix Issue 21850 - [REG2.093] Template inference of pure not working
https://github.com/dlang/dmd/pull/13149