Fix a bug in ternary ops with lhs reference types.