Can getHash be made pure?

Walter Bright newshound2 at digitalmars.com
Fri Mar 9 18:18:59 PST 2012


On 3/9/2012 5:15 PM, H. S. Teoh wrote:
> I tried to make getHash() const pure nothrow @safe, but found that in
> some places it calls toHash() which isn't marked const pure nothrow
> @safe.  So I fixed that as well, then found that toHash() calls
> toString() which isn't pure, nothrow, nor @safe... and before I knew it,
> I was deep into marking a *lot* of druntime functions (as perhaps they
> *should* be), and then I ran into this:
>
> src/object_.d(648): Error: function object.TypeInfo_AssociativeArray.next () is not callable using argument types ()
> src/object_.d(648): Error: function object.TypeInfo_AssociativeArray.next () is not callable using argument types ()
> src/object_.d(759): Error: function object.TypeInfo_Class.info () is not callable using argument types ()
> src/object_.d(1334): Error: cannot uniquely infer foreach argument types
> src/core/runtime.d(483): Error: cannot uniquely infer foreach argument types
> make: *** [lib/libdruntime-linux32.a] Error 1

Yeah, I know, it's viral. Can't do it piecemeal.


> A related question though: have we implemented automatic propagation of
> attributes like pure/nothrow/etc., yet? Just wondering if I can just
> modify the base class and have the attributes propagate, or I have to
> search for every override of every affected function in order to mark
> them (as I have been doing -- just wanted to make sure it isn't for
> nothing).

For 2.059, yes.


More information about the Digitalmars-d mailing list