[GHC] #14118: Strangeness regarding STG alternative types and linter

GHC ghc-devs at haskell.org
Fri Aug 25 09:05:55 UTC 2017


#14118: Strangeness regarding STG alternative types and linter
-------------------------------------+-------------------------------------
        Reporter:  bgamari           |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:  8.4.1
       Component:  Compiler          |              Version:  8.2.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D3858
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 > it seems like GHC is supposed to maintain the invariant that we will not
 use the case binder in the RHS if it is an unboxed tuple or sum

 Ah. That is true after the Unarise pass, but not before.  (That's a change
 we brought in a few years back.)  E.g. we can write
 {{{
 f :: (# Int, Bool #) -> Int
 f x = ...

 g :: Bool -> (# Int, Bool #)
 }}}
 and then call it thus
 {{{
 f (g True)
 }}}
 By the time we translate to STG that'll look like
 {{{
 case g True of (r :: (# Int, Bool #)) -> f r
 }}}
 and I think that's what is happening here.  But the Unarise pass
 transforms it to
 {{{
 case g True of (# (x::Int), (y::Bool) #) -> f x y
 }}}
 by making f take two explicit arguments.

 Can you check that the problem is gone after Unarise?   It'd be ideal for
 STG lint to have a flag that checked the stronger invariant after Unarise.

 Incidentally, this should also be true of lambda binders, whether used or
 not; before Unarise they can be unboxed tuples, but not after.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14118#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list