fix #4645, optimizer bug in variables used undefined