[GHC] #15242: Typechecker sometimes doesn't preserve HsPar in original source.

GHC ghc-devs at haskell.org
Thu Jun 7 10:37:14 UTC 2018


#15242: Typechecker sometimes doesn't preserve HsPar in original source.
-------------------------------------+-------------------------------------
           Reporter:  wz1000         |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.5
  (Type checker)                     |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  Other
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 The typechecker doesn't preserve parenthesis that occur at the head of
 applications.

 This results in some weird SrcSpans in the TypecheckedSource

 For example, given code

 {{{#!hs
 foo a b c = (bar a) b c
 }}}

 The typechecker will emit an HsApp with head spanning over `bar a) b` and
 tail spanning over `c`.
 Notice that the opening parenthesis is not included.

 On the other hand, the renamer will generate the expected SrcSpans that
 always include both parenthesis, or neither. This becomes an issue when
 you want to associate RenamedSource with its corresponding
 TypecheckedSource, as the SrcSpans no longer match and overlap partially.

 This occurs due to this line in TcExpr.hs

 {{{#!hs
 tcApp m_herald (L _ (HsPar _ fun)) args res_ty
   = tcApp m_herald fun args res_ty
 }}}

 I have a work in progress fix here:
 https://github.com/wz1000/ghc/commit/3b6db5a35dc8677a7187e349a85ffd51f452452a

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15242>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list