This is the second and final batch of refactors before the substantive changes. These patches basically: 1. Move some code from ast_to_hir.cpp to a new file. 2. Change around a bunch of error checks around array dereferences.