Programming Error: Unreachable Code Detected

Explanation:
This is generally when there is a fragment of code that can never be accessed under any circumstance. It’s a very general category. It might happen if you create an infinite loop that has code after it – since it’s infinite, it will never end to execute the next line. It can also happen if there is an impossible if/else, switch or other control structure. “Impossible” does not allow for any circumstance where it can happen. It is logically impossible.

Example:
while(true) {
Something();
}
OtherThing();

Solution:

Usually moving the inaccessible code, or changing the structure of your inaccessible code is necessary. Rethink the logic involved with making your algorithm. Since this is a very vague error that has many causes and solutions, you have to find the offending code yourself and move it.

Leave a comment