fix infinite loop when printing diagnostics