Fix correctness issues caused by reusing boilerplate code
There are two instances where a variable from a previous for-loop body is reused in an unrelated for-loop. It works by accident, but stores or prints the wrong element. The one for unions is particularly concerning since it maps the same random record (from the previous loop) to all union identifiers, leading to an incorrect index. There is another location where an assignment was forgotten. It is a "time bomb" since some codebase could trigger the code reading cls_method_desc when it's not previously defined (cls_method.doc is None branch), causing a runtime exception.
fix-copypaste in 1 minute and 46 seconds3 jobs for