As you have mentioned Compiler just checks syntatical errors.
the recursive function isperfectly valid w/o any error.
During Runtime,
when stack is overflown it throws an error because of stack overflow *not because of code*.
Recursive function is perfetly valid, but again in implementation we need to put condition check to return values before stack is filled.