Typechecker doesn't preserve HsPar in renamed source.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Typechecker doesn't preserve HsPar in renamed source.

Zubin Duggal
Hello all,

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

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: https://github.com/wz1000/ghc/commit/3b6db5a35dc8677a7187e349a85ffd51f452452a

I have also created a ticket on trac: https://ghc.haskell.org/trac/ghc/ticket/15242#ticket

_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

Re: Typechecker doesn't preserve HsPar in renamed source.

Richard Eisenberg-4
This looks pretty good to me. What's "in progress" about it?

I would want to see a comment on the declaration for HsArgPar with an example, and a test case.

Thanks!
Richard

On Jun 7, 2018, at 6:38 AM, Zubin Duggal <[hidden email]> wrote:

Hello all,

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

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: https://github.com/wz1000/ghc/commit/3b6db5a35dc8677a7187e349a85ffd51f452452a

I have also created a ticket on trac: https://ghc.haskell.org/trac/ghc/ticket/15242#ticket
_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

Re: Typechecker doesn't preserve HsPar in renamed source.

Zubin Duggal
At the time I hadn't modified tcSeq and tcTagToEnum to take HsArgPars into account. I have now done that, and also added a test case.

I've also submitted the fix to Phab, over here: https://phabricator.haskell.org/D4822

On 12 June 2018 at 09:04, Richard Eisenberg <[hidden email]> wrote:
This looks pretty good to me. What's "in progress" about it?

I would want to see a comment on the declaration for HsArgPar with an example, and a test case.

Thanks!
Richard

On Jun 7, 2018, at 6:38 AM, Zubin Duggal <[hidden email]> wrote:

Hello all,

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

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: https://github.com/wz1000/ghc/commit/3b6db5a35dc8677a7187e349a85ffd51f452452a

I have also created a ticket on trac: https://ghc.haskell.org/trac/ghc/ticket/15242#ticket
_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs



_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

Re: Typechecker doesn't preserve HsPar in renamed source.

Richard Eisenberg-4
Great -- and glad to see this getting appropriate attention over there.

Richard

On Jun 11, 2018, at 11:51 PM, Zubin Duggal <[hidden email]> wrote:

At the time I hadn't modified tcSeq and tcTagToEnum to take HsArgPars into account. I have now done that, and also added a test case.

I've also submitted the fix to Phab, over here: https://phabricator.haskell.org/D4822

On 12 June 2018 at 09:04, Richard Eisenberg <[hidden email]> wrote:
This looks pretty good to me. What's "in progress" about it?

I would want to see a comment on the declaration for HsArgPar with an example, and a test case.

Thanks!
Richard

On Jun 7, 2018, at 6:38 AM, Zubin Duggal <[hidden email]> wrote:

Hello all,

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

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: https://github.com/wz1000/ghc/commit/3b6db5a35dc8677a7187e349a85ffd51f452452a

I have also created a ticket on trac: https://ghc.haskell.org/trac/ghc/ticket/15242#ticket
_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs




_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs