[Issue 21850] New: Template inference of pure not working
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Apr 22 13:21:54 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=21850
Issue ID: 21850
Summary: Template inference of pure not working
Product: D
Version: D2
Hardware: x86_64
OS: All
Status: NEW
Severity: blocker
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: razvan.nitu1305 at gmail.com
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
--
More information about the Digitalmars-d-bugs
mailing list