diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2021-02-02 10:36:57 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2021-02-05 14:50:19 +0000 |
commit | bc92791c850ba0da1229abbd2444b177abbb29aa (patch) | |
tree | 27b2f848e012b2035c9c0e7ddaeb0d8b6e127788 /compiler | |
parent | ddbdec4128f0e6760c8c7a19344f2f2a7a3314bf (diff) | |
download | haskell-wip/T19279.tar.gz |
Fix buglet in expandSynTyCon_maybewip/T19279
The fix for #17958, implemented in MR !2952, introduced a small bug
in GHC.Core.TyCon.expandSynTyCon_maybe, in the case of under-saturated
type synonyms.
This MR fixes the bug, very easy.
Fixes #19279
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/GHC/Core/TyCon.hs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/GHC/Core/TyCon.hs b/compiler/GHC/Core/TyCon.hs index 4db3167bd7..efa6cfbcf7 100644 --- a/compiler/GHC/Core/TyCon.hs +++ b/compiler/GHC/Core/TyCon.hs @@ -2257,13 +2257,14 @@ expandSynTyCon_maybe -- type of the synonym (not yet substituted) -- and any arguments remaining from the -- application - --- ^ Expand a type synonym application, if any +-- ^ Expand a type synonym application +-- Return Nothing if the TyCon is not a synonym, +-- or if not enough arguments are supplied expandSynTyCon_maybe tc tys | SynonymTyCon { tyConTyVars = tvs, synTcRhs = rhs, tyConArity = arity } <- tc - = case tys of - [] -> Just ([], rhs, []) -- Avoid a bit of work in the case of nullary synonyms - _ -> case tys `listLengthCmp` arity of + = if arity == 0 + then Just ([], rhs, tys) -- Avoid a bit of work in the case of nullary synonyms + else case tys `listLengthCmp` arity of GT -> Just (tvs `zip` tys, rhs, drop arity tys) EQ -> Just (tvs `zip` tys, rhs, []) LT -> Nothing |