Tweak the semantics

Make some programs with duplicate type definitions result in type errors
that would have previously diverged.

Also check that a single datatype definition that defines multiple types
doesn't name the same type twice.