[GHC] #15696: Derived Ord instance for enumerations with more than 8 elements seems to be incorrect
GHC
ghc-devs at haskell.org
Tue Dec 11 23:21:06 UTC 2018
#15696: Derived Ord instance for enumerations with more than 8 elements seems to be
incorrect
-------------------------------------+-------------------------------------
Reporter: mrkkrp | Owner: osa1
Type: bug | Status: closed
Priority: highest | Milestone: 8.6.2
Component: Compiler | Version: 8.6.1
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Incorrect result | Test Case:
at runtime | codeGen/should_run/T15696_1,
| T15696_2, T15696_3
Blocked By: | Blocking:
Related Tickets: #14677, #15155 | Differential Rev(s): Phab:D5196,
Wiki Page: | Phab:D5201, Phab:D5226
-------------------------------------+-------------------------------------
Comment (by Ben Gamari <ben@…>):
In [changeset:"d549c081f19925dd0e4c70d45bded0497c649d49/ghc" d549c08/ghc]:
{{{
#!CommitTicketReference repository="ghc"
revision="d549c081f19925dd0e4c70d45bded0497c649d49"
dmdAnal: Move handling of datacon strictness to mkWWstr_one
Previously datacon strictness was accounted for when we demand analysed a
case
analysis. However, this results in pessimistic demands in some cases. For
instance, consider the program (from T10482)
data family Bar a
data instance Bar (a, b) = BarPair !(Bar a) !(Bar b)
newtype instance Bar Int = Bar Int
foo :: Bar ((Int, Int), Int) -> Int -> Int
foo f k =
case f of
BarPair x y -> case burble of
True -> case x of
BarPair p q -> ...
False -> ...
We really should be able to assume that `p` is already evaluated since it
came
from a strict field of BarPair.
However, as written the demand analyser can not conclude this since we may
end
up in the False branch of the case on `burble` (which places no demand on
`x`).
By accounting for the data con strictness later, applied to the demand of
the
RHS, we get the strict demand signature we want.
See Note [Add demands for strict constructors] for a more comprehensive
discussion.
Test Plan: Validate
Reviewers: simonpj, osa1, goldfire
Subscribers: rwbarton, carter
GHC Trac Issues: #15696
Differential Revision: https://phabricator.haskell.org/D5226
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15696#comment:91>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list