Added a bit more checking to the whole program semantics

Now there is a type error is any type or module in a whole program is
already defined in the initial environment, even if that declaration is
not reached in evaluation.