fixed a bug with same-type struct reference replacements