fix tuple counting bug in emit_tuple(set|ref)