variable declaration order-aware type checking, using ugly hack