www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17138] New: Warn about superfluous "with" statements

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

          Issue ID: 17138
           Summary: Warn about superfluous "with" statements
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: eyal weka.io

When using:

  with(someObject) {
    BODY;
  }

And none of the expressions within BODY actually use any members of
"someObject", and the destructor of "someObject" is not called at the end of
the "with" statement, it is a likely bug.

I use the following RAII idiom:

  with(someLock.acquired()) {
    ..
  }

But get no warning if I accidentally:

  with(someLock) {
  }

--
Feb 02