fix cyclic type output; add failed test case for type derivation