summaryrefslogtreecommitdiff
path: root/compiler/typecheck/TcBinds.hs
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@cs.stanford.edu>2016-10-28 17:54:36 -0700
committerEdward Z. Yang <ezyang@cs.stanford.edu>2016-11-16 21:31:59 -0800
commit31398fbc6d9ee0bd95de64b08becc38faf188972 (patch)
tree0ae632f650671447b96ce231781240b4d840097f /compiler/typecheck/TcBinds.hs
parentb76958671cda1df9f6f0e1d54d681144d09cb06e (diff)
downloadhaskell-31398fbc6d9ee0bd95de64b08becc38faf188972.tar.gz
Test for type synonym loops on TyCon.
Summary: Previously, we tested for type synonym loops by doing a syntactic test on the literal type synonym declarations. However, in some cases, loops could go through hs-boot files, leading to an infinite loop (#12042); a similar situation can occur when signature merging. This commit replaces the syntactic test with a test on TyCon, simply by walking down all type synonyms until we bottom out, or find we've looped back. It's a lot simpler. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonpj, austin, bgamari Subscribers: goldfire, thomie Differential Revision: https://phabricator.haskell.org/D2656 GHC Trac Issues: #12042
Diffstat (limited to 'compiler/typecheck/TcBinds.hs')
-rw-r--r--compiler/typecheck/TcBinds.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/typecheck/TcBinds.hs b/compiler/typecheck/TcBinds.hs
index 09746d3cba..60ef82671c 100644
--- a/compiler/typecheck/TcBinds.hs
+++ b/compiler/typecheck/TcBinds.hs
@@ -1134,7 +1134,9 @@ tcMonoBinds is_rec sig_fn no_gen
-- Single function binding,
| NonRecursive <- is_rec -- ...binder isn't mentioned in RHS
, Nothing <- sig_fn name -- ...with no type signature
- = -- In this very special case we infer the type of the
+ = -- Note [Single function non-recursive binding special-case]
+ -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ -- In this very special case we infer the type of the
-- right hand side first (it may have a higher-rank type)
-- and *then* make the monomorphic Id for the LHS
-- e.g. f = \(x::forall a. a->a) -> <body>