Bug fix for enumerations

Fix for a bug in TypeWithDict handling enumerations that causes fatal asserts in many "other" tests and some unit tests.
Please merge this simple fix as soon as convenient.