XS0162: Unreachable code detected

This forum is meant for questions and discussions about the X# language and tools
Post Reply
George
Posts: 106
Joined: Thu Nov 05, 2015 9:17 am

XS0162: Unreachable code detected

Post by George »

Hi again.

At compiling time, the previous application generates the error:

C:UsersGeorgeDocumentsVisual Studio 2015ProjectsXSharpApp1Form1 Methods.prg(68,2): warning XS0162: Unreachable code detected

at the RETURN statement (end of METHOD Listen_EntryPoint).

When I remove the RETURN statement, it compiles the project without errors.

I am attaching here a project showing the issue.

thanks and regards
George
App1.zip
(12.87 KiB) Downloaded 74 times
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

XS0162: Unreachable code detected

Post by FFF »

George,
EDIT: as Chris said.

(sorry, didn't really "read" the output, time to shut down eyes & computer ;)
fetched your code, doubleclicked the solution, VS2015 Community Edition loaded, "Build" - some seconds, "1 succeeded 0 fails". Looked for the Listen meth, "Return" is there. ??
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
Chris
Posts: 4898
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

XS0162: Unreachable code detected

Post by Chris »

Hi George,

I think this is a correct warning, isn't it? In the code there is a DO WHILE TRUE without an EXIT statement, so execution will never go out of this loop, and any code after it will not execute, thus the warning.

Chris
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
George
Posts: 106
Joined: Thu Nov 05, 2015 9:17 am

XS0162: Unreachable code detected

Post by George »

Chris,

>I think this is a correct warning, isn't it? In the code there is a DO WHILE TRUE without an EXIT statement, so execution will never go out of this loop, and any code after it will not execute, thus the warning.

That's true: Putting a conditional EXIT or RETURN inside the LOOP, it compiles.
But, the loop must be always present to listen into the System.Threading.Tasks.Task created by CreateParallelSocketServerTask Method.
And finally, calling the:
SELF:oSocketServer:Close()
at program's exit, the Task will be terminated. Right ?

regards
George
George
Posts: 106
Joined: Thu Nov 05, 2015 9:17 am

XS0162: Unreachable code detected

Post by George »

Hi Karl,

when you compiled (with X# of course) didn't you see the warning for the line:
68 (Form1 Methods.prg) ?

I am using the beta 0.9.

regards
George
User avatar
Chris
Posts: 4898
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

XS0162: Unreachable code detected

Post by Chris »

Hi George,

I'd assume that indeed this will terminate it, but on the other hand I don't have experience on socket programming, so better not take my assumption for a fact! :)

Maybe someone with experience in the area can help..

Chris
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply