digitalmars.D.learn - Fixing 18615, how to handle safe/pure/nothrow test breakage due to
Hi,
I'm trying to fix Bugzilla 18615, Rebindable!A doesn't use class
A's opEquals (returns a is b instead) [1]. The fix looks
reasonably obvious, my code is at [2]. Most of the added lines is
the unittest; the essence of the fix is:
struct RebindableCommon(/* ... */)
{
// ...
bool opEquals(ref const(typeof(this)) rhs) const
{
return this.original == rhs.original;
}
}
But this breaks several existing unittests throughout Phobos
because the comparison in object.d lacks safe, nogc, nothrow
and pure. For example, unittests in systime.d fail:
pure function [...]RebindableCommon[...].opEquals cannot call
impure function object.opEquals
nothrow function [...]RebindableCommon[...].opEquals may throw
std/datetime/systime.d(9006): Error: template instance
`std.typecons.Rebindable!(immutable(TimeZone))` error
instantiating
I'd rather not add attributes to the Rebindable.opEquals because
this function sits in a templated struct RebindableCommon, where
the compiler should deduce attributes automatically.
But I don't want to remove correct attributes from unittests in
systime.d either.
Can I reasonably continue here to fix 18615?
-- Simon
[1] https://issues.dlang.org/show_bug.cgi?id=18615
[2]
https://github.com/SimonN/phobos/commit/5a6fc6fd905b02e5ff93f2aaeaee2487fe8b38d0
Mar 28 2018
On Wednesday, 28 March 2018 at 15:04:27 UTC, Kagamin wrote:See line 1957, attributes are not inferred.Wow, that hit my blind spot. :-O Thanks. I've moved the RebindableCommon.opEquals outside of the attributes and all tests pass, as expected. -- Simon
Mar 28 2018








SimonN <eiderdaus gmail.com>