Fix debug assertions properly once and for all

[#72706522]
This and the next diff are just breaking up that massive line into a switch block.  Functionality is equivalent.