[WIP] fix gh-1344. Scan opt error/warning.

@razvan, can you review this?

Do you think we can optimize this case easily? In fact, in this case, we pushout nothing, do you see a way to remove only the first output? To remove both output?