diff options
author | Richard Eisenberg <rae@richarde.dev> | 2021-09-30 18:09:57 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-10-19 13:36:36 -0400 |
commit | 12d74ef77c1ded52b247cf21ff1012adf0408d70 (patch) | |
tree | 6341ce9923d14423073099707f4417e0ca60ed73 /compiler/GHC | |
parent | cfacac68970c4bcc632a25b641c89d331cd1a9f3 (diff) | |
download | haskell-12d74ef77c1ded52b247cf21ff1012adf0408d70.tar.gz |
Care about specificity in pattern type args
Close #20443.
Diffstat (limited to 'compiler/GHC')
-rw-r--r-- | compiler/GHC/Tc/Gen/Pat.hs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/compiler/GHC/Tc/Gen/Pat.hs b/compiler/GHC/Tc/Gen/Pat.hs index 332ea601b1..3d740948ca 100644 --- a/compiler/GHC/Tc/Gen/Pat.hs +++ b/compiler/GHC/Tc/Gen/Pat.hs @@ -1214,9 +1214,11 @@ tcConArgs con_like arg_tys tenv penv con_args thing_inside = case con_args of { checkTc (con_arity == no_of_args) -- Check correct arity (arityErr (text "constructor") con_like con_arity no_of_args) - ; let con_binders = conLikeUserTyVarBinders con_like - ; checkTc (type_args `leLength` con_binders) - (conTyArgArityErr con_like (length con_binders) (length type_args)) + -- forgetting to filter out inferred binders led to #20443 + ; let con_spec_binders = filter ((== SpecifiedSpec) . binderArgFlag) $ + conLikeUserTyVarBinders con_like + ; checkTc (type_args `leLength` con_spec_binders) + (conTyArgArityErr con_like (length con_spec_binders) (length type_args)) ; let pats_w_tys = zipEqual "tcConArgs" arg_pats arg_tys ; (type_args', (arg_pats', res)) @@ -1226,7 +1228,7 @@ tcConArgs con_like arg_tys tenv penv con_args thing_inside = case con_args of -- This unification is straight from Figure 7 of -- "Type Variables in Patterns", Haskell'18 ; _ <- zipWithM (unifyType Nothing) type_args' (substTyVars tenv $ - binderVars con_binders) + binderVars con_spec_binders) -- OK to drop coercions here. These unifications are all about -- guiding inference based on a user-written type annotation -- See Note [Typechecking type applications in patterns] |