fix a problem when generating primitives