Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#1219 closed merge (fixed)

RULE for take is too strict

Reported by: simonpj Owned by: igloo
Priority: normal Milestone: 6.6.1
Component: libraries/base Version: 6.6
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Easy (less than 1 hour)
Test Case: Blocked By:
Blocking: Related Tickets:

Description

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.

Change History (5)

comment:1 Changed 7 years ago by simonmar

  • Owner changed from simonmar to igloo
  • Type changed from bug to merge

Fixed, to merge in libraries/base:

Tue Mar 27 11:39:41 BST 2007  Simon Marlow <simonmar@microsoft.com>
  * fix strictness of foldr/build rule for take, see #1219

and testsuite:

Tue Mar 27 11:38:51 BST 2007  Simon Marlow <simonmar@microsoft.com>
  * add test for #1219

comment:2 Changed 7 years ago by igloo

  • Resolution set to fixed
  • Status changed from new to closed

Merged.

comment:3 Changed 6 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:4 Changed 6 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple

comment:5 Changed 4 years ago by simonmar

  • Difficulty changed from Easy (1 hr) to Easy (less than 1 hour)
Note: See TracTickets for help on using tickets.