[GHC] #10011: The Data instance for Ratio violates internal invariants.

GHC ghc-devs at haskell.org
Thu Jan 22 21:35:42 UTC 2015


#10011: The Data instance for Ratio violates internal invariants.
-------------------------------------+-------------------------------------
        Reporter:  ekmett            |                   Owner:
            Type:  bug               |                  Status:  new
        Priority:  normal            |               Milestone:  7.10.1
       Component:  Core Libraries    |                 Version:  7.10.1-rc1
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  Incorrect result  |  Unknown/Multiple
  at runtime                         |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:                    |  Differential Revisions:  Phab:D625
-------------------------------------+-------------------------------------

Comment (by Herbert Valerio Riedel <hvr@…>):

 In [changeset:"3df429e29b6fabda12af71091ba4ad1360f49b44/ghc"]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="3df429e29b6fabda12af71091ba4ad1360f49b44"
 Restore invariant in `Data (Ratio a)` instance

 (2nd attempt, this time leaving the `Constr` using `":%"`)

 The Data instance for `Ratio` just uses the raw `:%` constructor and
 doesn't check that the result is reduced to normal form.

 The fix is to add back the `Integral` constraint on the Data
 instance (which was dropped in c409b6f30373535) and to use `%` rather
 than `:%` in the `gfoldl` and `gunfold` implementation.

 This restores the invariant and matches the behavior of "virtual
 constructors" we've used to patch up such problems elsewhere.

 This addresses #10011

 Reviewed By: ekmett, austin

 Differential Revision: https://phabricator.haskell.org/D625
 }}}

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


More information about the ghc-tickets mailing list