Fix assertion failure with type conversion in for-generate