X10
  1. X10
  2. XTENLANG-322

v.equals(v) returns false for x10 values

    Details

    • Number of attachments :
      0

      Description

       value V {}
      
      public class Bug {
          public static def main(var args: Rail[String]): void = {
              val v = new V();
              x10.runtime.NativeRuntime.println(v.equals(v).toString());
          }
      }
      

      outputs false.

        Issue Links

          Activity

          Hide
          Dave Cunningham added a comment -

          v == v checks the pointers, i.e. is broken since new V() != new V()

          v.equals(v) is broken because value V does not have a ::equals method, thus inherits Value::equals which only returns true when given another concrete instance of Value

          We should generate a .equals for every value that looks like this

          bool equals (ref<Object> other) {
              if (other == this) return true;
              if (other->type != this->type) return false;  // see Value::equals for how to do this
              if (other->f1 != this->f1) return false;
              if (other->f2 != this->f2) return false;
              ...
              if (other->fn != this->fn) return false;
              return true;
          }
          

          Alternatively we can try and write a general equals() inside Value that uses memcmp, but that will mean new V() == new Value() and we will also have to memset to 0 on allocation to make sure all padding is 0

          Show
          Dave Cunningham added a comment - v == v checks the pointers, i.e. is broken since new V() != new V() v.equals(v) is broken because value V does not have a ::equals method, thus inherits Value::equals which only returns true when given another concrete instance of Value We should generate a .equals for every value that looks like this bool equals (ref< Object > other) { if (other == this ) return true ; if (other->type != this ->type) return false ; // see Value::equals for how to do this if (other->f1 != this ->f1) return false ; if (other->f2 != this ->f2) return false ; ... if (other->fn != this ->fn) return false ; return true ; } Alternatively we can try and write a general equals() inside Value that uses memcmp, but that will mean new V() == new Value() and we will also have to memset to 0 on allocation to make sure all padding is 0
          Hide
          Igor Peshansky added a comment -

          Now that we have a regression script, upgrading to Blocker.

          Show
          Igor Peshansky added a comment - Now that we have a regression script, upgrading to Blocker.
          Hide
          Igor Peshansky added a comment -

          This should now be fixed. However, I may have missed adding _struct_equals to some hand-written value class. Please verify.

          Show
          Igor Peshansky added a comment - This should now be fixed. However, I may have missed adding _struct_equals to some hand-written value class. Please verify.
          Hide
          David Grove added a comment -

          Bulk close of old resolved issues.

          Show
          David Grove added a comment - Bulk close of old resolved issues.

            People

            • Assignee:
              Igor Peshansky
              Reporter:
              Olivier Tardieu
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: