roll back on errors during type definitions. fixes #5009