fix #6306, regression in type inference of constant conditions due to
rearrangement of while loop conditions