BUG Bad inspection says Expression is always false

Example which shows the problem:

        var keyToValue=new Dictionary<int, int> {{0, 0}, {1, 1}};
        var ids=new List<int> {1, 2, 3};
        var removed=false;
        foreach(var id in ids) {
          removed=keyToValue.Remove(id)|removed;
        }


ReSharper's inspection logic underlines the right-hand-side of the loop body assignment and says "Expression is always false".

This is definitely not the case for the example above. At the end of the loop, removed is true.

This inspection bug does not arise if I reverse the order of the bitwise-or operands:

        foreach(var id in ids) {
          removed=removed|keyToValue.Remove(id);
        }


I've confirmed the bug in Resharper 6.1.37.86 on Visual Studio 10.0.40219.1.

Thanks
1 comment
Comment actions Permalink

Hello Naju
     Thank you very much for reporting this problem! I've logged it under http://youtrack.jetbrains.net/issue/RSRP-287532 in our bug-tracker and you're welcome to monitor its status.

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0

Please sign in to leave a comment.