Thread overview
[Issue 14948] [Reg 2.068.0] AA key requirement was broken w/o notice and w/ horrible error message
Aug 25, 2015
Kenji Hara
Aug 25, 2015
Kenji Hara
Aug 31, 2015
Kenji Hara
Aug 31, 2015
Kenji Hara
Aug 31, 2015
Kenji Hara
August 25, 2015
https://issues.dlang.org/show_bug.cgi?id=14948

--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> ---
The reproduce case I can guess (HTTP is a struct in std.net.curl):

void main()
{
    import std.net.curl;
    int[HTTP] aa;
}

The error message "AA key type X supports const equality but doesn't support const hashing" has introduced from 2.066.

http://dlang.org/changelog/2.066.0.html#aa-key-requirement

If a struct has elaborate equality but doesn't have corresponding hash calculation, the error will be reported to avoid silent AA behavior breaking.

When we change the requirement for AA key from ordering to equality, we decided to change everything at once. Therefore no deprecation pass had been introduced there.

In 2.068, issue 14806 has been fixed. HTTP struct is defined as follows:

struct HTTP {
    ...
    private RefCounted!Impl p;
}

By that bug fix, it's silently changed to a struct which has elaborate field-wise equality without corresponding toHash method.

In short, it's a problem in the definition of HTTP struct. It had had to be detected and fixed before the 2.066 release, but unfortunately it wasn't.

--
August 25, 2015
https://issues.dlang.org/show_bug.cgi?id=14948

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
          Component|dmd                         |phobos

--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> ---
Changed to Phobos issue.

--
August 25, 2015
https://issues.dlang.org/show_bug.cgi?id=14948

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy@yahoo.com

--- Comment #3 from Steven Schveighoffer <schveiguy@yahoo.com> ---
I think there are 2 separate issues here:

1. HTTP struct is not correct
2. Error message is horrible, we need to know where the AA was instantiated to
be able to fix this.

Can we have an issue for each?

--
August 31, 2015
https://issues.dlang.org/show_bug.cgi?id=14948

--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> ---
(In reply to Steven Schveighoffer from comment #3)
> 2. Error message is horrible, we need to know where the AA was instantiated to be able to fix this.

With my reduced test case, the error message prints line 4, it's where the AA type int[HTTP] is declared.

--
August 31, 2015
https://issues.dlang.org/show_bug.cgi?id=14948

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|phobos                      |dmd

--- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> ---
OK, I noticed this is a compiler issue.

Usually D compiler automatically generates toHash member function by using TypeInfo.getHash function. But in particular case it had not worked.


Reduced test case:

struct RefCounted(T)
{
    struct Impl
    {
        T data;
    }
    Impl* impl;

    @property ref T payload() { return impl.data; }

    alias payload this;
}

struct HTTP
{
    struct Impl
    {
    }

    RefCounted!Impl p;
}

void main()
{
    int[HTTP] aa;
}

The root problem is very similar to issue 14806.

--
August 31, 2015
https://issues.dlang.org/show_bug.cgi?id=14948

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #6 from Kenji Hara <k.hara.pg@gmail.com> ---
https://github.com/D-Programming-Language/dmd/pull/5001

--
September 02, 2015
https://issues.dlang.org/show_bug.cgi?id=14948

--- Comment #7 from github-bugzilla@puremagic.com ---
Commits pushed to stable at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/5c1d3c5b63394b7d3758f86a53eace6ffb3d3165
fix Issue 14948 - AA key requirement was broken w/o notice and w/ horrible
error message

https://github.com/D-Programming-Language/dmd/commit/880f45dafe5b45951f5b30d188130b32250d6e31 Merge pull request #5001 from 9rnsr/fix14948

[REG2.068] Issue 14948 - AA key requirement was broken w/o notice and w/ horrible error message

--
September 07, 2015
https://issues.dlang.org/show_bug.cgi?id=14948

--- Comment #8 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/5c1d3c5b63394b7d3758f86a53eace6ffb3d3165
fix Issue 14948 - AA key requirement was broken w/o notice and w/ horrible
error message

https://github.com/D-Programming-Language/dmd/commit/880f45dafe5b45951f5b30d188130b32250d6e31 Merge pull request #5001 from 9rnsr/fix14948

--