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
1
vote
3 answers

break; line unreachable

String userAge; while(true){ System.out.println("Enter user Age"); userAge = scInput.nextLine(); if(tryParseInt(userAge)){ return userInfo[row][1] = userAge; break; }else{ …
Reagan B
  • 23
  • 2
1
vote
1 answer

Is it the only case a reachable goto pointing to an unreachable label?

Inspired from question What is a non-reachable end point(unreachable endpoint) of a statement? And before I ask this question, I've read: C# Puzzle : Reachable goto pointing to an unreachable label Why does this "finally" execute? The challenge…
Ken Kin
  • 4,503
  • 3
  • 38
  • 76
0
votes
5 answers

Unreachable Code Detected Warning

Alright, so I've been trying to fix this for a good while now. I have a "warning" within my code - "Unreachable Code Detected". I'm not sure how to fix this, which is why I'm posting here. Below is the code: public static byte…
0
votes
4 answers

Why is this code giving an "Unreachable Statement" error?

This is my code and im getting an unreachable statement error on it but i do not know why. public boolean Boardload(String[] args) throws Exception { Robot robot = new Robot(); Color color3 = new Color(114, 46, 33); Color color4 = new…
user1179522
  • 145
  • 1
  • 3
  • 8
0
votes
1 answer

Code is unreachable but I have no return function

This is my first post so I am sorry if I make any mistakes writing this. So I'm making a calculator program as my first personal program after learning enough on how to code with python. But I ran into a problem when adding the functions. When I…
Mearri
  • 3
  • 3
0
votes
1 answer

"This code is unreachable" warning in pycharm

The following part of my code is highlighted as code unreachable in pycharm IDE. for row in range(frame_height): for col in range(frame_width): if i < binary_img.shape[0]: pixel =…
Heeya
  • 11
  • 3
0
votes
1 answer

Why my boolean is unreachable code and compilation error?

I am doing a leave management system for my assignment. And this is the part where I ask user to save their registration. First, I use do...while(true) loop to ask for their info like name, ID , department, etc. I start with adding a boolean regErr…
0
votes
0 answers

How to verify the source code that cannot be tested

I wrote all possible tests according to the requirements, made an analysis of the structural coverage (to make sure that I reached full coverage), added tests based on the results of the conducted analysis. However, there are still areas of code…
0
votes
1 answer

How should I handle logically unreachable code

I have a class implementing an interface which forces me to implement 2 methods - fun check(): Boolean and fun onCheckFalse(): Int. The usage looks something like: if (check().not()) return onCheckFalse() In my implementation, I always return true…
orirab
  • 2,915
  • 1
  • 24
  • 48
0
votes
2 answers

Why is This React Code Unreachable When Its an Array But Works for a Single Object

Hi I want to use the map function to iterate over my data and populate a table in React. Using State I set my variable to an empty array but when I come to Map it the code is unreachable and I have no idea why. Note: If I map an individual object…
Matt
  • 23
  • 6
0
votes
1 answer

How to pattern match objects in Scala

I am trying to use pattern matching on a List of objects. The method takes in queue: List[ScheduleChangeEvent]. ScheduleChangeEvent is a sealed trait with 4 different final case class's. Therefore, depending on what type of ScheduleChangeEvent the…
0
votes
0 answers

C# Idiomatic runtime expression which always evaluates to true but is not detected as compile-time constant

I would like to have a C# runtime expression which always evaluates to true, but which the compiler does not recognize as a constant. (Motivation below) There are plenty of ways to achieve this, but I'm wondering if there's a nice most-idiomatic…
0
votes
1 answer

Cant access Instance Variables Inside Typescript Methods | It says the variable is unreachable

class User { public pname: string; private ptoken: string; public token_status:boolean = false; public constructor(pname: string, ptoken: string) { this.pname = pname; this.ptoken = ptoken; } public…
0
votes
1 answer

Why does Java never reach the end of this if/else?

I've been scratching my head at this for hours now, but I can't seem to figure this one out. I'm writing a program that has a constant loop going in a Thread, which occasionally sends back data to another part of the program using an Arraylist. I…
0
votes
0 answers

How to fix the 'This code is unreachable' error in PyCharm

while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() ball.x += ball_speed_x #This line is unreachable ball.y += ball_speed_y It doesn't matter what I type in that…
EMM-J
  • 1
  • 3