Opened 3 years ago

Closed 3 years ago

#10263 closed bug (fixed)

Role annotation should never be ambiguous

Reported by: ezyang Owned by: goldfire
Priority: normal Milestone: 7.10.2
Component: Compiler (Type checker) Version: 7.11
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case: roles/should_compile/T10263
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

[ezyang@hs01 ghc-backpack]$ cat A.hs
{-# LANGUAGE RoleAnnotations #-}
module A where
data Maybe a = AF
type role Maybe representational
[ezyang@hs01 ghc-backpack]$ ghc -c A.hs

A.hs:4:11:
    Ambiguous occurrence ‘Maybe’
    It could refer to either ‘A.Maybe’, defined at A.hs:3:1
                          or ‘Prelude.Maybe’,
                             imported from ‘Prelude’ at A.hs:2:8
                             (and originally defined in ‘GHC.Base’)

This is silly because roles can only ever be defined with the declaration, so only one reference makes sense.

Change History (6)

comment:1 Changed 3 years ago by simonpj

Owner: set to goldfire

You are quite right. I have not looked into how role annotations are renamed, but presumably they are rather like signatures. For those we use RnEnv.lookupSigOccRn.

comment:2 Changed 3 years ago by Richard Eisenberg <eir@…>

In 6ab5da9913e4f8a8dcc8bda3c77d4e896fd67352/ghc:

Rename role annotations w.r.t only local decls.

Fix #10263.

comment:3 Changed 3 years ago by goldfire

Milestone: 7.10.2
Status: newmerge
Test Case: roles/should_compile/T10263

Merge if convenient.

comment:4 Changed 3 years ago by ezyang

Woohoo, thanks!

comment:5 Changed 3 years ago by thoughtpolice

Merged to ghc-7.10.

comment:6 Changed 3 years ago by thoughtpolice

Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.