Typechecker doesn't preserve HsPar in renamed source.
zubin.duggal at gmail.com
Thu Jun 7 10:38:01 UTC 2018
The typechecker doesn't preserve parenthesis that occur at the head of
This results in some weird SrcSpans in the TypecheckedSource
For example, given code
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
tcApp m_herald (L _ (HsPar _ fun)) args res_ty
= tcApp m_herald fun args res_ty
I have a work in progress fix here:
I have also created a ticket on trac:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ghc-devs