Fix compiler bug where duplicate type declarations caused crash.
And add missing test. The test runs and fails with the previous cfa compiler.