Skip to content

Missing Note about linear types, maybe redundant code too

In GHC.Core.Opt.Simplify.Iteration I see this comment

Since this transformation is tantamount to a binder swap, the same caveat as in
Note [Suppressing binder-swaps on linear case] in OccurAnal apply.

It annotates this code in that same module:

             -- See Note [Add unfolding for scrutinee]
             env2 | Many <- idMult case_bndr = case scrut of
                      Just (Var v) -> addBinderUnfolding env1 v con_app_unf

However

  • There is no Note [Suppressing binder-swaps on linear case]
  • I can see nothing analogous in OccurAnal

This comment was introduced in the mega-patch when linear types landed

commit 40fa237e1daab7a76b9871bb6c50b953a1addf23
Author: Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io>
Date:   Mon Jun 15 19:58:10 2020 +0200

    Linear types (#15981)

This was before we had linting to detect bad Note references. Questions

  1. Can we get rid of the Many <- idMult case_bndr guard above?
  2. Or do we instead need to add something in OccurAnal?
Edited by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information