typecheck if and while statements