Rework the Implicit CallStack solver to handle local lets.
authorEric Seidel <gridaphobe@gmail.com>
Sat, 12 Dec 2015 15:53:50 +0000 (16:53 +0100)
committerBen Gamari <ben@smart-cactus.org>
Sat, 12 Dec 2015 17:39:22 +0000 (18:39 +0100)
commit3ec8288a18d57fb856e257905897daae237a1d5d
tree089c791781000e8685cac8f70c53e12a971288b7
parent1883afb2eee88c828adf6aa8014bab64dd6e8096
Rework the Implicit CallStack solver to handle local lets.

We can't just solve CallStack constraints indiscriminately when they
occur in the RHS of a let-binder. The top-level given CallStack (if
any) will not be in scope, so I've re-worked the CallStack solver as
follows:

1. CallStacks are treated like regular IPs unless one of the following
   two rules apply.

2. In a function call, we push the call-site onto a NEW wanted
   CallStack, which GHC will solve as a regular IP (either directly from a
   given, or by quantifying over it in a local let).

3. If, after the constraint solver is done, any wanted CallStacks
   remain, we default them to the empty CallStack. This rule exists mainly
   to clean up after rule 2 in a top-level binder with no given CallStack.

In rule (2) we have to be careful to emit the new wanted with an
IPOccOrigin instead of an OccurrenceOf origin, so rule (2) doesn't fire
again. This is a bit shady but I've updated the Note to explain the
trick.

Test Plan: validate

Reviewers: simonpj, austin, bgamari, hvr

Reviewed By: simonpj, bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1422

GHC Trac Issues: #10845
38 files changed:
.gitignore
compiler/deSugar/DsBinds.hs
compiler/typecheck/TcEvidence.hs
compiler/typecheck/TcHsSyn.hs
compiler/typecheck/TcInteract.hs
compiler/typecheck/TcRnTypes.hs
compiler/typecheck/TcSimplify.hs
compiler/utils/Outputable.hs
docs/users_guide/7.12.1-notes.rst
docs/users_guide/glasgow_exts.rst
libraries/base/GHC/Exception.hs
libraries/base/GHC/IO/Exception.hs
libraries/base/GHC/Stack.hs
libraries/base/GHC/Stack/Types.hs
libraries/base/changelog.md
testsuite/.gitignore
testsuite/tests/codeGen/should_run/cgrun059.stderr
testsuite/tests/concurrent/should_run/conc021.stderr
testsuite/tests/ghci.debugger/scripts/break011.stdout
testsuite/tests/ghci.debugger/scripts/break017.stdout
testsuite/tests/ghci.debugger/scripts/print033.stdout
testsuite/tests/ghci/scripts/T5557.stdout
testsuite/tests/ghci/scripts/T8959.stdout
testsuite/tests/ghci/scripts/ghci013.stdout
testsuite/tests/ghci/scripts/ghci046.stdout
testsuite/tests/ghci/scripts/ghci055.stdout
testsuite/tests/partial-sigs/should_compile/ExtraConstraints3.stderr
testsuite/tests/partial-sigs/should_fail/T10999.stderr
testsuite/tests/pmcheck/should_compile/T3927b.stderr
testsuite/tests/th/T1849.script
testsuite/tests/typecheck/should_run/IPLocation.hs
testsuite/tests/typecheck/should_run/IPLocation.stdout
testsuite/tests/typecheck/should_run/T10845.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_run/T10845.stdout [new file with mode: 0644]
testsuite/tests/typecheck/should_run/T10846.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_run/T10846.stdout [new file with mode: 0644]
testsuite/tests/typecheck/should_run/T8119.stdout
testsuite/tests/typecheck/should_run/all.T