[Issue 24359] New: slice equality expression can be discarded
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jan 29 11:25:57 UTC 2024
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 at puremagic.com
Reporter: dkorpel at 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.
--
More information about the Digitalmars-d-bugs
mailing list