The compiler does not check for values of variables. It only sees your while-loop with a boolean variable
int Method {
while([a variable]) {
<Optional path>
}
<Path that is checked>
}
and notes that if it would be false your method does not return an int as it was said it would.
See this answer for a more detailed explanation based on the C# language specification.