[GHC] #15805: Bug in anyRewritableTyVar
#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
#15805: Bug in anyRewritableTyVar -------------------------------------+------------------------------------- Reporter: ningning | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #14363 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Wow -- good catch. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15805#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15805: Bug in anyRewritableTyVar -------------------------------------+------------------------------------- Reporter: ningning | Owner: ningning Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #14363 | Differential Rev(s): Phab:D5263 Wiki Page: | -------------------------------------+------------------------------------- Changes (by ningning): * owner: (none) => ningning * differential: => Phab:D5263 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15805#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15805: Bug in anyRewritableTyVar -------------------------------------+------------------------------------- Reporter: ningning | Owner: ningning Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #14363 | Differential Rev(s): Phab:D5263 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"a7f64c6cbfc5562adff207945576d1c9db2a58d9/ghc" a7f64c6c/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="a7f64c6cbfc5562adff207945576d1c9db2a58d9" Fix TcType.anyRewritableTyVar Summary: This patch fixes #15805, where we found that `TcType.anyRewritableTyVar` has one wrong case. Besides the fix, it also: - removed some unnecessary `ASSERT2(tcIsTcTyVar...)` in `TcType`, as now we have `tcIsTcTyVar = isTyVar`. - fixed some comments Test Plan: ./validate Reviewers: goldfire, simonpj, bgamari Reviewed By: simonpj Subscribers: rwbarton, carter GHC Trac Issues: #15805 Differential Revision: https://phabricator.haskell.org/D5263 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15805#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15805: Bug in anyRewritableTyVar -------------------------------------+------------------------------------- Reporter: ningning | Owner: ningning Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #14363 | Differential Rev(s): Phab:D5263 Wiki Page: | -------------------------------------+------------------------------------- Changes (by ningning): * status: new => closed * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15805#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15805: Bug in anyRewritableTyVar -------------------------------------+------------------------------------- Reporter: ningning | Owner: ningning Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #14363 | Differential Rev(s): Phab:D5263 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Ningning, is there a test case? Ideally we'd come up with one, knowing the bug. But not worth losing sleep over if it's hard to do so. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15805#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC