Fix #5483
Merge pull request #5486 from JuliaLang/sjk/loop-fix

Fix #5483