Issue #1327 regression test and fix

Hi Travis, I came up with a regression test and a fix, please merge or cherry-pick.

As commented previously, I believe the case throw null` has no impact here.