Questions tagged [unreachable-code]

Unreachable code is part of the source code of a program which can never be executed because there exists no control flow path to the code from the rest of the program.

181 questions
2
votes
0 answers

Why does an exhaustively returning switch fail to compile if there is code following it?

Why does this code fail to compile when using noImplicitReturns... function foo(bar: "a"): number { switch (bar) { case "a": return 1; } let unreachable; } error TS2366: Function lacks ending return statement…
Kendall Frey
  • 43,130
  • 20
  • 110
  • 148
2
votes
3 answers

Unreachable Code Detected

I'm about ready to deploy an MVC web application that I've been tasked with managing (I did not create the application). The project is now compiling in production mode with no errors, however I have some warnings - 9 to be precise. Now 6 are to do…
109221793
  • 16,477
  • 38
  • 108
  • 160
2
votes
1 answer

Nested if returning unreachable code

I'm doing a (pseudo) AI interface of questions and answers, my 'answer' class is a bunch of if's statements: if "a" in message then return this "b". I want to be able to give it more depth, by inserting nested if's, but that second if is giving…
Kaka
  • 151
  • 1
  • 1
  • 9
2
votes
4 answers

My Return Statement is Unreachable

public BigDecimal calculateTotal() { BigDecimal percent = BigDecimal.valueOf(0.9); int i = 0; BigDecimal price = BigDecimal.valueOf(0.0); while(!myOrders.isEmpty()){ if (!myOrders.get(i).getItem().isBulk() && myMembership ==…
2
votes
2 answers

Unreachable code with multiple catch statements

Why does line 2 compile while line 3 does not? spit() throws a HurtException that has already been caught on line 1, so any checked exception that comes afterwards should be unreachable. If I delete line 2, line 3 will remain reachable. Exceptions…
Helenesh
  • 3,999
  • 2
  • 21
  • 36
2
votes
1 answer

How to force call site analysis when finding dead code in Polyspace?

I use Polyspace IHME-8.1.0.12 (R2011a) to find dead code in my project. Currently, the analysis catches this case: int f1() { int x = 1; if (x > 0) return 1; else return 0; // dead code } But not this case: int f2(int x) { if (x > 0)…
Dmitry Grigoryev
  • 3,156
  • 1
  • 25
  • 53
2
votes
3 answers

for each loop in an iterator method

Check out this program: static class Program { static void Main() { GetLinks(); Console.WriteLine("Program failed!"); } static IEnumerable GetLinks() { throw new Exception(); foreach (var item in new string[] { }) …
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
2
votes
1 answer

Statements outside for loop are not being executed

I'm new to Java. I found a website called project eulder and was practicing on a problem. I don't understand why the following program does not display anything but when I put System.out.println(max); into the for loop it works but displaying all…
chelayel
  • 47
  • 5
2
votes
0 answers

Label Missing error after Decompiling - Android

I recently decompiled a apk. I extracted the source code. But when i try to run it in Eclipse, I m getting Label Missing Error. Here is my code snippet: (Errors are written as comments) private void changeRadioComponentEnabled(Context paramContext,…
trueblue
  • 306
  • 1
  • 5
  • 17
2
votes
4 answers

C# Excel Function - unreachable code detected

I'm attempting to create a function class in C# for use in an excel Automation add-in. Using the simple code below, I was wanting to add the values in a range that match the colour that the user selects (for example, sum Range("A1:A10") where the…
2
votes
2 answers

Playing around with buttons in Windows Forms

I'm on to a small project where I try to make my own web browser. I found out that a web browser is worthless without "New Tabs"-function, so I thought that I could use buttons as tabs and every time I press "ctrl + T" a new button appears. The…
2
votes
0 answers

Visual studio not marking unreachable throw as unreachable

Visual Studio 2010 marks, underlines the statement in green, the return in the else clause as unreachable which is logical. public void UnreachableElse() { if (true) //If true will always evaluate to true. return; …
Synergyze
  • 23
  • 3
2
votes
1 answer

*INLR and while(true) in RPG

I'm looking at some legacy programs, where code like the following is found: C/free Dow 1=1; SubRoutine(); EndDo; *INLR = *On; /end-free The program in question is a server-like program, where the sub routine handles incoming…
Eyvind
  • 5,221
  • 5
  • 40
  • 59
2
votes
2 answers

Suppress unreachable errors in PyDev?

I have some Python code from a course I'm taking and am seeing errors in some of the files that test for support of particular features and won't try to use them if the features are not present. In my case, I don't have the feature available, so…
Jeff Axelrod
  • 27,676
  • 31
  • 147
  • 246
1
vote
1 answer

Unreachable case except for null in scala

I have the following helper function. I am trying to create a word frequency List. (a,b,a) => [(a,2),(b,1)]: def add_to_lop(c:Char, lop: List[(Char, Int)]):List[(Char, Int)] = { lop match { case List() => List((c,1)) case (c,…