Ticket #5236 (closed bug: fixed)

Opened 2 years ago

Last modified 2 years ago

Circular functional dependencies cause loop in typechecker

Reported by: dimitris Owned by:
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 7.0.3
Keywords: Cc: simonpj@…, stevez@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty:
Test Case: typecheck/should_fail/T5236.hs Blocked By:
Blocking: Related Tickets:

Description

In the attached file, a dictionary (Id A B) is rewritten with two functional dependencies (A -> B, B -> A) and two errors are added in our constraint bag (rightfully so), but the new workitem is symmetric (Id B A), goes back in the worklist and in the new iteration of the solver we have exactly the same process repeated.

This is a solveInteractWithDepth loop, not a solve_wanteds loop. I think the right thing to do is in doTopReact: (1) first try to apply functional dependencies, (2) then check if an instance matches, and (3) do a ContinueWith? or a Stop but never throw the workitem back in the worklist as happens now. I have to discuss this with Simon.

Attachments

TestLoop.hs Download (271 bytes) - added by dimitris 2 years ago.

Change History

Changed 2 years ago by dimitris

Changed 2 years ago by dimitris

  • status changed from new to closed
  • testcase set to typecheck/should_fail/T5236.hs
  • resolution set to fixed

OK, I just pushed the fix:

commit 107715b367678d1325a5eecd4a4f13ba6ada3c6c Author: Dimitrios Vytiniotis <dimitris@…> Date: Wed Jun 8 18:24:21 2011 +0100

Reorganized functional dependency reactions once more:

1) generating Derived FDs as happens for equality superclasses 2) Kept the optimization of immediately discharging items

if fundeps cause a match

3) Restructured top-reactions and interactions with inerts to

behave similarly to each other.

In particular, (1) fixes ticket #5236.

compiler/typecheck/TcCanonical.lhs | 108 +++++++++------- compiler/typecheck/TcInteract.lhs | 256 ++++++++++++++++++++---------------- 2 files changed, 204 insertions(+), 160 deletions(-)

Note: See TracTickets for help on using tickets.