The dict-bindings in an IPBinds need not be in dependency order
authorsimonpj@microsoft.com <unknown>
Mon, 3 Jul 2006 15:15:17 +0000 (15:15 +0000)
committersimonpj@microsoft.com <unknown>
Mon, 3 Jul 2006 15:15:17 +0000 (15:15 +0000)
This appears to be a long-standing bug, discovered by BlueSpec
(ravi@bluespec.com), Trac bug #795

The problem was that in an IP binding group, the dict bindings
aren't necessarily in dependency order; and if they aren't
we get a core-lint error.

Test tc203 checks this case.  (Though whether it shows up at
all depends a bit on accidental factors of binding ordering.)

compiler/deSugar/DsExpr.lhs

index f7b232c..5fb0ec8 100644 (file)
@@ -85,7 +85,9 @@ dsValBinds (ValBindsOut binds _) body = foldrDs ds_val_bind body binds
 -------------------------
 dsIPBinds (IPBinds ip_binds dict_binds) body
   = do { prs <- dsLHsBinds dict_binds
-       ; let inner = foldr (\(x,r) e -> Let (NonRec x r) e) body prs 
+       ; let inner = Let (Rec prs) body
+               -- The dict bindings may not be in 
+               -- dependency order; hence Rec
        ; foldrDs ds_ip_bind inner ip_binds }
   where
     ds_ip_bind (L _ (IPBind n e)) body