www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24359] New: slice equality expression can be discarded

https://issues.dlang.org/show_bug.cgi?id=24359

          Issue ID: 24359
           Summary: slice equality expression can be discarded
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: minor
          Priority: P3
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dkorpel live.nl

```D
void main()
{
    3 == 3; // Error: the result of the equality expression `3 == 3` is
discarded
    "" == ""; // No error
}
```

This probably happens because the expression gets lowered to `__equals("",
"")`.
The above case is a bit silly, but I accidentally wrote this in a struct
member:

```D
this.slice == this.slice[0 .. 0];
```

Which could have been caught by the compiler.

--
Jan 29