[dmd-beta] D 1.074 and 2.059 betas 2

Nick Sabalausky bus_dmdbeta at semitwist.com
Sat Apr 7 14:21:17 PDT 2012


From: "Nick Sabalausky" <bus_dmdbeta at semitwist.com>
> While the test case for #7826 now works, for some reason I'm still getting 
> the same warning in my own projects (but without "pure" being included in 
> "must be declared as...") even though they which use the *exact* same 
> toHash function (well, except "str" having a different name). I'll try to 
> figure out a new test case after I get some sleep...
>

/facepalm: With Beta2, I wasn't getting the probelem with the original test 
case (ie "const hash_t toHash()") because I wasn't compiling it with 
warnings enabled.

So here's the "issue" now, *if* it even is an issue (I'm not sure):

With Beta2's current fix for #7826, I can do this without warnings or 
errors:

    struct Foo {
        string str;
        const nothrow @safe hash_t toHash() {
            return typeid(string).getHash(&str);
        }
    }

But, this (ie, removing nothrow and/or @safe):

    struct Foo {
        string str;
        const hash_t toHash() {
            return typeid(string).getHash(&str);
        }
    }

Gives me a warning:

Warning: toHash() must be declared as extern (D) uint toHash() const nothrow 
@safe, not const uint()

Is this the correct behavior or not? Jonathan's comment over here ( 
http://d.puremagic.com/issues/show_bug.cgi?id=7826 ) suggested that toHash 
in a struct shouldn't require nothrow or @safe. I'm refraining from having 
any opinion on the matter ATM, I just wanted to bring it up in case the 
current fix is incomplete.



More information about the dmd-beta mailing list