API Annotations : ExprWithTySig processing discards annotated spans
authorAlan Zimmerman <alan.zimm@gmail.com>
Tue, 14 Apr 2015 12:32:40 +0000 (07:32 -0500)
committerAustin Seipp <austin@well-typed.com>
Tue, 14 Apr 2015 12:33:25 +0000 (07:33 -0500)
commit8dc294487fdaf102349c373c7db4796693573310
tree4816125b3b6457fc7d20353fedb8614d533dc626
parent79bfe27d9157fb3d44b4cc64f168bc11191d3f9b
API Annotations : ExprWithTySig processing discards annotated spans

In RdrHsSyn.checkAPat the processing for ExprWithTySig is defined as

   ExprWithTySig e t _ -> do e <- checkLPat msg e
                             -- Pattern signatures are parsed as sigtypes,
                             -- but they aren't explicit forall points.  Hence
                             -- we have to remove the implicit forall here.
                             let t' = case t of
                                        L _ (HsForAllTy Implicit _ _
                                             (L _ []) ty) -> ty
                                        other -> other
                             return (SigPatIn e (mkHsWithBndrs t'))

The t' variable ends up losing its original SrcSpan in the first case
branch. This results in annotations becoming detached from the AST.

Reviewed By: austin

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

GHC Trac Issues: #10255
compiler/parser/RdrHsSyn.hs
testsuite/tests/ghc-api/annotations/.gitignore
testsuite/tests/ghc-api/annotations/Makefile
testsuite/tests/ghc-api/annotations/T10255.stderr [new file with mode: 0644]
testsuite/tests/ghc-api/annotations/T10255.stdout [new file with mode: 0644]
testsuite/tests/ghc-api/annotations/Test10255.hs [new file with mode: 0644]
testsuite/tests/ghc-api/annotations/all.T
testsuite/tests/ghc-api/annotations/t10255.hs [new file with mode: 0644]