Bug 24359 – slice equality expression can be discarded

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-01-29T11:25:57Z
Last change time
2024-01-31T03:44:14Z
Keywords
accepts-invalid, pull
Assigned to
No Owner
Creator
Dennis

Comments

Comment #0 by dkorpel — 2024-01-29T11:25:57Z
```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.
Comment #1 by dlang-bot — 2024-01-29T11:56:23Z
@dkorpel created dlang/dmd pull request #16111 "Fix bugzilla issue 24359 - slice equality expression can be discarded" fixing this issue: - Fix bugzilla issue 24359 - slice equality expression can be discarded https://github.com/dlang/dmd/pull/16111
Comment #2 by dlang-bot — 2024-01-31T03:44:14Z
dlang/dmd pull request #16111 "Fix bugzilla issue 24359 - slice equality expression can be discarded" was merged into master: - 8d89feb226a4b444624a5cc84666ac799ddeed89 by Dennis Korpel: Fix bugzilla issue 24359 - slice equality expression can be discarded https://github.com/dlang/dmd/pull/16111