Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9061995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:37:29+00:00 2026-06-16T15:37:29+00:00

I am trying to compare two associative arrays, each containing some structs, to see

  • 0

I am trying to compare two associative arrays, each containing some structs, to see if they are equal to each other, but I am getting an error and I don’t know why. It happens if the structs have an opEquals function. Comparing traditional (non-associative) arrays with the same kind of structs works fine. Here is a simple program that illustrates the problem:

#! /usr/bin/rdmd
import std.stdio;

void main() {
    // outputs "true"
    writeln([Thing()] == [Thing()]);

    // throws an error
    writeln(["foo": Thing()] == ["foo": Thing()]);
}

struct Thing {
    /* This function needs to be defined to trigger the error but it doesn't
       seem to matter what I put in it. */
    bool opEquals(ref Thing other) {
        return true;
    }
}

Here is the error message:

object.Error: TypeInfo.equals is not implemented
----------------
5   structAaTest                        0x0000000100003b20 const(pure nothrow @trusted bool function(const(void*), const(void*))) object.TypeInfo_Struct.equals + 64
6   structAaTest                        0x0000000100013a70 extern (C) int rt.aaA._aaEqual(TypeInfo, rt.aaA.AA, rt.aaA.AA).int _aaKeys_x(rt.aaA.aaA*) + 152
7   structAaTest                        0x00000001000139ad _aaEqual + 261
8   structAaTest                        0x0000000100000fbb _Dmain + 319
9   structAaTest                        0x00000001000151de extern (C) int rt.dmain2.main(int, char**).void runMain() + 34
10  structAaTest                        0x0000000100014b95 extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate()) + 45
11  structAaTest                        0x0000000100015228 extern (C) int rt.dmain2.main(int, char**).void runAll() + 56
12  structAaTest                        0x0000000100014b95 extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate()) + 45
13  structAaTest                        0x0000000100014b1f main + 235
14  structAaTest                        0x0000000100000e74 start + 52
15  ???                                 0x0000000000000001 0x0 + 1
----------------

I am using DMD v2.060 and OS X 10.6.8.

Does anyone know why this is happening, whether it is intended behavior or a bug, and what to do about it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T15:37:30+00:00Added an answer on June 16, 2026 at 3:37 pm

    Try changing your opEquals to be const and non-ref.

    bool opEquals(Thing other) const {
         return true;
    }
    

    I think dmd recently changed to be a lot stricter about the opEquals signature.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to compare two arrays to see if they match- My test cases
simply trying to compare two user defined vectors to see if they are equal,
Hi I am trying to compare two arrays to each other and then hide
I'm trying to compare two strings with each other on the iphone, but the
I'm trying to compare two UIImages from the file system to see if they
I am trying to compare two Lists using CollectionAssert.AreEqual(ListExpected, ListActual); But I am getting
I'm trying to compare two strings and for some reason, I'm getting false as
I'm trying to compare two datepicker dates and see if they are more than
I am trying to compare two dates but I can t see how it
I am trying to compare two strings in Smalltalk, but I seem to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.