summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/GHC/Core/TyCon.hs11
-rw-r--r--testsuite/tests/ghci/scripts/T19279.script3
-rw-r--r--testsuite/tests/ghci/scripts/T19279.stdout3
-rwxr-xr-xtestsuite/tests/ghci/scripts/all.T1
4 files changed, 13 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
diff --git a/testsuite/tests/ghci/scripts/T19279.script b/testsuite/tests/ghci/scripts/T19279.script
new file mode 100644
index 0000000000..b414e1dc8b
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T19279.script
@@ -0,0 +1,3 @@
+type T a = a
+:kind! T
+:kind T
diff --git a/testsuite/tests/ghci/scripts/T19279.stdout b/testsuite/tests/ghci/scripts/T19279.stdout
new file mode 100644
index 0000000000..fe7fbbf9f8
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T19279.stdout
@@ -0,0 +1,3 @@
+T :: * -> *
+= T
+T :: * -> *
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index 08a6c4ee6a..a85fe27fd3 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -328,4 +328,5 @@ test('T18755', normal, ghci_script, ['T18755.script'])
test('T18828', normal, ghci_script, ['T18828.script'])
test('T19197', normal, ghci_script, ['T19197.script'])
test('T19158', normal, ghci_script, ['T19158.script'])
+test('T19279', normal, ghci_script, ['T19279.script'])