stryker-net icon indicating copy to clipboard operation
stryker-net copied to clipboard

Use of unassigned local variable

Open nheath99 opened this issue 3 years ago • 2 comments

Describe the bug I receive the warning "Stryker.NET encountered an compile error...with message: Use of unassigned local variable 'result'", and I'm asked to report this to GitHub. Please see the following repo for a minimum reproduction of the issue: https://github.com/nheath99/StrykerDemo It seems to occur whenever a variable is declared but not initialised, and then used later in the method.

Logs log-20220221.txt

Expected behavior I would not expect this exception to be thrown.

Desktop (please complete the following information):

  • OS: Windows 11
  • Type of project core
  • Framework Version 6.0
  • Stryker Version 1.3.1

Additional context Add any other context about the problem here.

nheath99 avatar Feb 21 '22 22:02 nheath99

I've seen code like

int x; if(a) { x = 1; } else { x = 2 } return x;

fail, but if x is explicitly initialized it does not fail i.e. int x = 0;

Steve-P-Allen avatar Mar 08 '22 09:03 Steve-P-Allen

I'm also dealing with a project that generates many errors like the one described above. There are so many, that even 50 compilation retries are not enough to compile it successfully.

andrepm06 avatar Mar 14 '22 10:03 andrepm06

Note that you will get rid of this errors if you disable Block mutators!.

dupdob avatar Oct 24 '22 10:10 dupdob

I can't seem to reproduce this issue anymore. Please reopen if another reproduction is found.

richardwerkman avatar May 26 '23 11:05 richardwerkman