[GHC] #15805: Bug in anyRewritableTyVar

GHC ghc-devs at haskell.org
Thu Oct 25 13:09:10 UTC 2018


#15805: Bug in anyRewritableTyVar
-------------------------------------+-------------------------------------
           Reporter:  ningning       |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:  #14363
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 The current implementation of `TcType.anyRewritableTyVar` has one wrong
 case:

 {{{#!hs
     go_tc ReprEq bvs tc tys = foldr ((&&) . go_arg bvs) False $
                               (tyConRolesRepresentational tc `zip` tys)
 }}}

 Here `foldr` uses `&&` in the function and a `False` as the initial value,
 which causes this case to always return `False` no matter what the inputs
 are.

 This bug is introduced in
 [changeset:"3acd6164fea6d4d5d87521a291455a18c9c9a8ee/ghc" 3acd616/ghc],
 which is for fixing #14363.

 The correct implementation (I think) should use `||` instead of `&&`:

 {{{#!hs
     go_tc ReprEq bvs tc tys = foldr ((||) . go_arg bvs) False $
                               (tyConRolesRepresentational tc `zip` tys)
 -- or just
     go_tc ReprEq bvs tc tys = any (go_arg bvs) (tyConRolesRepresentational
 tc `zip` tys)
 }}}

 We presume that there might be some program which loops because of this
 bug.

 Patch incoming.

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


More information about the ghc-tickets mailing list