I have programmed in c# for a good while. But I cannot find out how unity is compiling this code successfully.
Is there a feature of c# that I am not knowing about here?
NOTE: The only return statement in the function is commented out.
public List<Hex> GetPath(Hex start, Hex end) {
PathfindManager<Hex, PathReciever>.RequestPath(start, end, this);
while (true) {
lock (_lockObject) {
if (_pathRecieved) {
var path = _path;
_pathRecieved = false;
_path = null;
//return path;
}
}
}
}
I wonder if it is because there is no code path to reach the end of the function and return to whatever called it in the first place. You call this and get stuck in the while loop forever, so since the function can never return it doesn’t matter it doesn’t return the correct type? Just a guess
Try changing the infinite loop to something that could actually reach the end of the function and see what happens.
Thanks for the response. Changing the loop to does cause it to throw an error. This was a result of me accidentally commenting out the wrong line while I was trying to get something done real fast, catching myself midway, and wondering why it still compiled. What you are saying about the infinite loop does appear to be a reasonable explanation.