Commit 393928db authored by Simon Peyton Jones's avatar Simon Peyton Jones

Fix renamer panic

This patch fixes Trac #12216 and #12127.  The 'combine' function
in 'imp_occ_env' in RnNames.filterImports checked for an empty
field-selector list, which was (a) unnecessary and (b) wrong.

I've elaborated the comments.

This does NOT fix #11959 which is related but not the same
(it concerns bundling of pattern synonyms).
parent c871ce49
......@@ -743,8 +743,15 @@ The situation is made more complicated by associated types. E.g.
instance C Bool where { data T Int = T3 }
Then M's export_avails are (recall the AvailTC invariant from Avails.hs)
C(C,T), T(T,T1,T2,T3)
Notice that T appears *twice*, once as a child and once as a parent.
From this we construct the imp_occ_env
Notice that T appears *twice*, once as a child and once as a parent. From
this list we construt a raw list including
T -> (T, T( T1, T2, T3 ), Nothing)
T -> (C, C( C, T ), Nothing)
and we combine these (in function 'combine' in 'imp_occ_env' in
'filterImports') to get
T -> (T, T(T,T1,T2,T3), Just C)
So the overall imp_occ_env is
C -> (C, C(C,T), Nothing)
T -> (T, T(T,T1,T2,T3), Just C)
T1 -> (T1, T(T,T1,T2,T3), Nothing) -- similarly T2,T3
......@@ -797,12 +804,13 @@ filterImports iface decl_spec (Just (want_hiding, L l import_items))
imp_occ_env = mkOccEnv_C combine [ (nameOccName n, (n, a, Nothing))
| a <- all_avails, n <- availNames a]
where
-- See example in Note [Dealing with imports]
-- 'combine' is only called for associated types which appear twice
-- in the all_avails. In the example, we combine
-- See Note [Dealing with imports]
-- 'combine' is only called for associated data types which appear
-- twice in the all_avails. In the example, we combine
-- T(T,T1,T2,T3) and C(C,T) to give (T, T(T,T1,T2,T3), Just C)
combine (name1, a1@(AvailTC p1 _ []), mp1)
(name2, a2@(AvailTC p2 _ []), mp2)
-- NB: the AvailTC can have fields as well as data constructors (Trac #12127)
combine (name1, a1@(AvailTC p1 _ _), mp1)
(name2, a2@(AvailTC p2 _ _), mp2)
= ASSERT( name1 == name2 && isNothing mp1 && isNothing mp2 )
if p1 == name1 then (name1, a1, Just p2)
else (name1, a2, Just p1)
......
module T12127 where
import T12127a( T(..), C(..) )
{-# LANGUAGE TypeFamilies #-}
module T12127a where
class C a where
data T a
instance C Int where
data T Int = MkT { x, y :: Int }
......@@ -238,3 +238,7 @@ test('T11662',
[extra_clean(['T11662_A.hi', 'T11662_A.o'])],
multimod_compile,
['T11662', '-v0'])
test('T12127',
[extra_clean(['T12127a.hi', 'T12127a.o'])],
multimod_compile,
['T12127', '-v0'])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment