Fix type checking of struct fields in patterns of type ty_err

Fixes #16338.
Fixed #16401.