Skip to content
  • Simon Peyton Jones's avatar
    Ensure nested binders have Internal Names · baf9ebe5
    Simon Peyton Jones authored
    This is a long-standing bug.  A nested (non-top-level) binder
    in Core should not have an External Name, like M.x. But
    
    - Lint was not checking this invariant
    
    - The desugarer could generate programs that failed the
      invariant.  An example is in
      tests/deSugar/should_compile/T13043, which had
         let !_ = M.scState in ...
      This desugared to
         let ds = case M.scSate of M.scState { DEFAULT -> () }
         in case ds of () -> ...
    
      We were wrongly re-using that scrutinee as a case binder.
      And Trac #13043 showed that could ultimately lead to two
      top-level bindings with the same closure name.  Alas!
    
    - The desugarer had one other place (in DsUtils.mkCoreAppDs)
      that could generate bogus code
    
    This patch fixes all three bugs, and adds a regression test.
    baf9ebe5