Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#8522 closed bug (fixed)

exprType incorrect for let expressions which bind types

Reported by: afarmer Owned by:
Priority: high Milestone:
Component: Compiler Version: 7.6.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


The exprType function in CoreUtils doesn't handle let expressions which bind type variables correctly. Consider:

let a = Int
in \ $dNum x y -> (+) a $dNum x y

exprType on this expression will give: Num a => a -> a -> a instead of Num Int => Int -> Int -> Int

Obviously the core lint checker does the right thing, so I modified exprType (see attached patch) to do what it does. I'm guessing that exprType isn't used in any crucial capacity (or let-bound types are not that common) or the fact that a is unbound in the result would be a big problem. That said, we use this function heavily in HERMIT... is there another we should be using instead?

Any chance this can make the 7.8 window?

Attachments (1)

Fix-exprType-s-handling-of-let-bound-types.patch (1.1 KB) - added by afarmer 3 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 3 years ago by afarmer

Status: newpatch

comment:2 Changed 3 years ago by Simon Peyton Jones <simonpj@…>

In 96e6eddc40c34a171f6261a7814a1e264457ce86/ghc:

Make exprType work correctly in the presnce of type bindings (Trac #8522)

comment:3 Changed 3 years ago by simonpj

OK done. I've implemented it slightly differently

Last edited 3 years ago by simonpj (previous) (diff)

comment:4 Changed 3 years ago by simonpj

Resolution: fixed
Status: patchclosed

It's not easy to make a test case, so closing.


Note: See TracTickets for help on using tickets.