Bug 12267 – [REG 2.065] Using struct as AA key sometimes require opCmp

Status
RESOLVED
Resolution
DUPLICATE
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-26T09:52:00Z
Last change time
2014-02-27T12:49:44Z
Assigned to
nobody
Creator
doob

Comments

Comment #0 by doob — 2014-02-26T09:52:08Z
There's a struct declared in Tango [1] as follows: struct TagIndex { uint tag; uint index; } The above should not need to define a custom opCmp to be used as an AA key. Unfortunately I haven't been able to find a reduced test case. [1] https://github.com/SiegeLord/Tango-D2/blob/94471d6b5282dde78fae8be7924fe3fa389c1900/tango/text/Regex.d#L2366-L2385
Comment #1 by dlang-bugzilla — 2014-02-26T22:07:44Z
(In reply to comment #0) > Unfortunately I haven't been able to find a reduced test case. Um? struct S {} int[S] aa; That's your reduced test case right there. Compiles in 2.064.2 but not 2.065.0. Anyway, this has already been filed as issue 12255. *** This issue has been marked as a duplicate of issue 12255 ***
Comment #2 by doob — 2014-02-26T23:16:21Z
I'm pretty sure that the simple case with two uints did compile in 2.065. But not the case in Tango.
Comment #3 by dlang-bugzilla — 2014-02-26T23:18:34Z
That's not what I'm seeing: C:\Temp\D\issues\12267> "C:\Downloads\!dmd\dmd.2.065.0\dmd2\windows\bin\dmd.exe" -o- test.d test.d(2): Error: associative array key type S does not have 'const int opCmp(ref const S)' member function Please check again. If the simple case above compiles for you, please post the exact compiler version, operating system, etc.
Comment #4 by doob — 2014-02-27T12:13:26Z
(In reply to comment #3) > That's not what I'm seeing: > > C:\Temp\D\issues\12267> > "C:\Downloads\!dmd\dmd.2.065.0\dmd2\windows\bin\dmd.exe" -o- test.d > test.d(2): Error: associative array key type S does not have 'const int > opCmp(ref const S)' member function > > Please check again. If the simple case above compiles for you, please post the > exact compiler version, operating system, etc. If I import std.stdio it compiles.
Comment #5 by dlang-bugzilla — 2014-02-27T12:48:44Z
Well, isn't this interesting. This compiles: struct T { int opCmp() { return 2; } } struct S {} int[S] aa; That is, it is enough to add an opCmp to ANY struct to unbreak compilation.
Comment #6 by doob — 2014-02-27T12:49:44Z
(In reply to comment #5) > Well, isn't this interesting. > > This compiles: > > struct T { int opCmp() { return 2; } } > > struct S {} > int[S] aa; > > > That is, it is enough to add an opCmp to ANY struct to unbreak compilation. Haha, that's weird.