Commit 0c7d2d75 authored by Committed by Krzysztof GogolewskiBrowse files
Fix Trac #8368.
Two different fixes were necessary here. First, we need to fail eagerly in kcConDecl, to prevent the return-type error in tcConDecl from firing twice. (This wasn't caught earlier because of the eager fail in the datatype kind-checking code -- which isn't used for data instances!) We also must check again in tcDataFamInstDecl, because it's possible for a data instance return type to have the right head but the wrong body (i.e., doesn't conform to the data instance type patterns). This check is only possible *after* desugaring from HsType to Type, so it can't be done in tcConRes with the first check. This is documented in a comment at check_valid_data_con, a local function within tcDataFamInstDecl.