Fix edge case in generate code that prevents useful error message from being displayed.