Strange "Statement is not reachable"
Orgoton
orgoton at mindless.com
Fri Mar 23 05:49:46 PDT 2007
I created and Actor Class like this:
class Actor
{
public this()
{
frameQ[this.type].add(this); //add myself to the queue
HP=this.MaxHP;
MP=this.MaxMP;
if (this.type==ActorType.Other) return;
if (heartQ[0].size()>heartQ[1].size()) heartQ[1].add(this);
else heartQ[0].add(this);
if (this.type==ActorType.Creature) AIQ.add(this);
return; /*****/
}
public final static const ActorType type=ActorType.Other;
}
(ignore functions calls, they aren't relevant)
and then on the Player Class
public class Player : Actor
{
public this(float x, float y, ubyte level)
{
this.level=level;
super(x, y);
}
public final static const ActorType type=ActorType.HumanPlayer;
}
Now the problem lies on the line marked with "***" (the return statement in Actor's ctr). If it is there, DMD says that "statement is not reachable" without giving me any information on why or which line:
semantic2 actor
semantic3 actor
warning - Error: statement is not reachable
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
So, if I remove the "return;", the program compiles fine. What happened?
Btw, it is my (Assembly) programming habit to put a "return;" at the end of every function, even if it is not void or is unreachable.
More information about the Digitalmars-d
mailing list