Ticket #1370 (closed bug: fixed)

Opened 6 years ago

Last modified 5 years ago

Obscure loop in interaction between arity and case-of-bottom

Reported by: simonpj Owned by: simonpj
Priority: normal Milestone: 6.8.3
Component: Compiler Version: 6.6.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: simpl-T1370 Blocked By:
Blocking: Related Tickets:

Description

John Meacham discovered that this program makes the simplifier loop:

newtype T = V T deriving(Eq,Ord)

It's a silly program, but it shouldn't kill GHC! I investigated and the reason is because we get this:

  rec { compare :: T -> T -> Ordering
        compare [arity 2] = compare }
   
  max :: T -> T -> T
  max x y = case compare x y of { GT -> x; other -> y }

The real bug is that compare has been eta-reduced, but still has arity 2. That's wrong. Anyway, since compare diverges, we get

  max x y = compare `cast` UnsafeCoerce (T->T->T) T

and now we try to eta-expand the RHS of max, and that is a stupid thing to do (and loops in CoreUtils.etaExpand.

The real bug is the unsound eta-reducion for compare, which I knew about (comments in Note [Add IdInfo back onto a let-bound Id] in SimplEnv).

It's a dark corner case, and I'm not going to fix it today.

Change History

Changed 6 years ago by simonpj

  • owner set to simonpj

Changed 6 years ago by guest

Changed 6 years ago by simonpj

  • milestone changed from 6.8 branch to 6.8.3

Changed 5 years ago by simonpj

  • status changed from new to closed
  • testcase set to simpl-T1370
  • resolution set to fixed

Actually this is fixed by the same patch as #1947, namely:

Tue Dec  4 14:58:03 GMT 2007  simonpj@microsoft.com
  * Make eta reduction check more carefully for bottoms (fix Trac #1947)

I added a test case simpl-T1370 to make sure it stays fixed.

Simon

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.