www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10045] New: Missed warning with wrong toHash() + toHash documentation

http://d.puremagic.com/issues/show_bug.cgi?id=10045

           Summary: Missed warning with wrong toHash() + toHash
                    documentation
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2013-05-08 04:31:46 PDT ---
struct Foo1 {
     hash_t toHash() {
        return 0;
    }
}
struct Foo2 {
     hash_t toHash() const { // line 7.
        return 0;
    }
}
struct Foo3 {
     hash_t toHash() const nothrow  safe {
        return 0;
    }
}
void main () {
    int[Foo1] aa1;
    aa1[Foo1()] = 1;
    int[Foo2] aa2;
    aa2[Foo2()] = 2;
    int[Foo3] aa3;
    aa3[Foo3()] = 3;
}



Compiling with -wi DMD 2.063beta gives:

temp2.d(7): Warning: toHash() must be declared as extern (D) size_t toHash()
const nothrow  safe, not const uint()


Expected:

temp2.d(2): Warning: toHash() must be declared as extern (D) size_t toHash()
const nothrow  safe, not const uint()
temp2.d(7): Warning: toHash() must be declared as extern (D) size_t toHash()
const nothrow  safe, not const uint()


Additionally I think the site documentation of the section "Using Structs or
Unions as the KeyType" should be updated:
http://dlang.org/hash-map.html

Because it shows signatures that are different from the one required in the
warning:

const hash_t opHash();
const bool opEquals(ref const KeyType s);
const int opCmp(ref const KeyType s);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 08 2013