Merge pull request #2774 from WalterBright/fix8525

fix Issue 8525 - optimizer loops infinitely