Fix some edge cases in 8f8bd88c (#7134)

Signed-off-by: Austin Seipp <austin@well-typed.com>

(cherry picked from commit fda9bebc61cab7235123b50dc70dbf30f0140dad)