Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code is heuristically unreachable

Tags:

c#

resharper

What does this mean in contrast to "unreachable code detected"?

like image 976
bevacqua Avatar asked Apr 03 '11 21:04

bevacqua


People also ask

What does heuristically unreachable mean?

Does resharper actually say that? Heuristically unreachable means possibly unreachable code. Unreachable code is certainly unreachable. I'm finding this cropping up when it's impossible for me or ReSharper to know whether something is always going to be false (or == null ).

What are the causes of unreachable code?

Unreachable Code Causes: Programming errors while developing complex conditional branches. Incomplete unit testing because of which unreachable code was undetected. Redundant code that developer forgot to delete. The code that might be programmatically correct but won't be executed at any point of time due to the input data ...

Why does ReSharper give cryptic heuristically unreachable code warning?

Here's an example of ReSharper giving the cryptic "Heuristically unreachable code" warning: ReSharper being way too smart for itself, because if you remove it the compiler will complain about a lack of a return statement Say you're deleting 2 different kinds of objects in a unit test and you want to use a try/catch for both types.

What is unreachable error in Java?

Unreachable Code Error in Java. The Unreachable statements refers to statements that won’t get executed during the execution of the program are called Unreachable Statements. These statements might be unreachable because of the following reasons: Have a return statement before them. Have an infinite loop before them.


2 Answers

Here's an example of ReSharper giving the cryptic "Heuristically unreachable code" warning:

enter image description here

It's an example of:

  • ReSharper being way too smart for itself, because if you remove it the compiler will complain about a lack of a return statement
  • Use of a word that is not common lexicon
like image 44
Ben Power Avatar answered Sep 21 '22 10:09

Ben Power


Heuristically unreachable means possibly unreachable code. Unreachable code is certainly unreachable.

like image 114
Adrian Marinica Avatar answered Sep 19 '22 10:09

Adrian Marinica