[Issue 17245] New: Errors about expressions with no effect only are given for basic types

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Mar 7 07:11:33 PST 2017


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

          Issue ID: 17245
           Summary: Errors about expressions with no effect only are given
                    for basic types
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: jack at jackstouffer.com

Example

void main () {
    Object a, b;
    a == b;
}

gives no error.

The problem lies, as ketmar put it, with opEquals

> oops. no more error messages. yes, i know that this invokes 
> `opEquals()`, and `opEquals()` can have side-effects. but what 
> are the chances of writing such code *intentionally*?

Here, the compiler can be helpful by outputing an error if the used opEquals is
marked as pure. There's no way that a pure opEquals should be used in an
expression with no effect.

--


More information about the Digitalmars-d-bugs mailing list