RULE for take is too strict
main = print (map (const 'x') (take 1 (undefined:undefined)))
In ghci, or with ghc -O0, this produces "x". With ghc -O, this produces Prelude.undefined. Kirsten Chevalier found that the culprit is the RULE:
"take" [~1] forall n xs . take n xs
= case n of I# n# -> build (\c nil -> foldr (takeFB c nil)
(takeConst nil) xs n#)
This rule makes take strict in xs, but it should be lazy when n=0.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 6.6 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | libraries/base |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |