[Resharper 4.1] Is this a bug? "Value assigned is not used in any execution path"

In this code, Resharper says that "flag = true" can be removed.

            bool flag = false;
            Action<Action> b = a =>
                       {
                           flag = true;
                           a();
                           flag = false;
                       };

            b(() => Console.WriteLine(flag));

Try it, and you will see that this changes the output of the program from "True" to "False".

2 comments

Looks like a bug to me. State captured by a closure shouldn't trigger that indicator from R#.

0

This is bug, and it is already fixed in 4.5

--
Eugene Pasynkov
ReSharper Technical Lead
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


"Jeremy Gray" <no_reply@jetbrains.com> wrote in message
news:24841838.45271234374131992.JavaMail.clearspace@app4.labs.intellij.net...

Looks like a bug to me. State captured by a closure shouldn't trigger that
indicator from R#.

>

---
Original message URL:
http://www.jetbrains.net/devnet/message/5231896#5231896



0

Please sign in to leave a comment.