Commit 72a92726 authored by eir@cis.upenn.edu's avatar eir@cis.upenn.edu

Change default roles in hs-boot files. (#9204)

Test case: roles/should_compile/T9204b
parent dc587fe7
......@@ -460,7 +460,7 @@ tcRnImports hsc_env import_decls
************************************************************************
-}
tcRnSrcDecls :: ModDetails
tcRnSrcDecls :: ModDetails
-> Maybe (Located [LIE RdrName]) -- Exports
-> [LHsDecl RdrName] -- Declarations
-> TcM TcGblEnv
......@@ -736,7 +736,7 @@ checkHiBootIface' :: [ClsInst] -> TypeEnv -> [AvailInfo]
-- Variant which doesn't require a full TcGblEnv; you could get the
-- local components from another ModDetails.
--
-- We return a list of "impedence-matching" bindings for the dfuns
-- We return a list of "impedence-matching" bindings for the dfuns
-- defined in the hs-boot file, such as
-- $fxEqT = $fEqT
-- We need these because the module and hi-boot file might differ in
......@@ -996,9 +996,9 @@ checkBootTyCon tc1 tc2
where
roles1 = tyConRoles tc1
roles2 = tyConRoles tc2
roles_msg = text "The roles do not match." <+>
(text "Roles default to" <+>
quotes (text "representational") <+> text "in boot files")
roles_msg = text "The roles do not match." $$
(text "Roles on abstract types default to" <+>
quotes (text "representational") <+> text "in boot files.")
eqAlgRhs tc (AbstractTyCon dis1) rhs2
| dis1 = check (isDistinctAlgRhs rhs2) --Check compatibility
......@@ -1921,7 +1921,7 @@ getModuleInterface hsc_env mod
= runTcInteractive hsc_env $
loadModuleInterface (ptext (sLit "getModuleInterface")) mod
tcRnLookupRdrName :: HscEnv -> Located RdrName
tcRnLookupRdrName :: HscEnv -> Located RdrName
-> IO (Messages, Maybe [Name])
-- ^ Find all the Names that this RdrName could mean, in GHCi
tcRnLookupRdrName hsc_env (L loc rdr_name)
......
......@@ -684,9 +684,9 @@ initialRoleEnv1 is_boot annots_env tc
zipWith orElse role_annots (repeat default_role)
default_role
| isClassTyCon tc = Nominal
| is_boot = Representational
| otherwise = Phantom
| isClassTyCon tc = Nominal
| is_boot && isAbstractTyCon tc = Representational
| otherwise = Phantom
irGroup :: RoleEnv -> [TyCon] -> RoleEnv
irGroup env tcs
......
......@@ -59,7 +59,18 @@
See the release notes for base for a description of the
<literal>CallStack</literal> type.
</para>
</listitem>
</listitem>
<listitem>
<para>
To conform to the common case, the default role assigned to parameters
of datatypes declared in <literal>hs-boot</literal> files is
<literal>representational</literal>. However, if the constructor(s)
for the datatype are given, it makes sense to do normal role inference.
This is now implemented, effectively making the default role for
non-abstract datatypes in <literal>hs-boot</literal> files to be
<literal>phantom</literal>, like it is in regular Haskell code.
</para>
</listitem>
</itemizedlist>
</sect3>
......
......@@ -878,7 +878,7 @@ methods entirely; but you must either omit them all or put them all in.
</para></listitem>
<listitem><para> You can include instance declarations just as in Haskell; but omit the "where" part.
</para></listitem>
<listitem><para>The default role for class and datatype parameters is now representational. To get another role, use a role annotation. (See <xref linkend="roles"/>.)</para></listitem>
<listitem><para>The default role for abstract datatype parameters is now representational. (An abstract datatype is one with no constructors listed.) To get another role, use a role annotation. (See <xref linkend="roles"/>.)</para></listitem>
</itemizedlist>
</para>
</sect2>
......
RnFail055.hs:1:73: Warning:
RnFail055.hs:1:73: warning:
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
RnFail055.hs-boot:1:73: Warning:
RnFail055.hs-boot:1:73: warning:
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
RnFail055.hs-boot:4:1:
RnFail055.hs-boot:4:1: error:
Identifier ‘f1’ has conflicting definitions in the module
and its hs-boot file
Main module: f1 :: Int -> Float
Boot file: f1 :: Float -> Int
The two types are different
RnFail055.hs-boot:6:1:
RnFail055.hs-boot:6:1: error:
Type constructor ‘S1’ has conflicting definitions in the module
and its hs-boot file
Main module: type S1 a b = (a, b)
Boot file: type S1 a b c = (a, b)
The types have different kinds
RnFail055.hs-boot:8:1:
RnFail055.hs-boot:8:1: error:
Type constructor ‘S2’ has conflicting definitions in the module
and its hs-boot file
Main module: type S2 a b = forall a1. (a1, b)
Boot file: type S2 a b = forall b1. (a, b1)
The roles do not match. Roles default to ‘representational’ in boot files
The roles do not match.
Roles on abstract types default to ‘representational’ in boot files.
RnFail055.hs-boot:12:1:
RnFail055.hs-boot:12:1: error:
Type constructor ‘T1’ has conflicting definitions in the module
and its hs-boot file
Main module: data T1 a b = T1 [b] [a]
Boot file: data T1 a b = T1 [a] [b]
The constructors do not match: The types for ‘T1’ differ
RnFail055.hs-boot:14:1:
RnFail055.hs-boot:14:1: error:
Type constructor ‘T2’ has conflicting definitions in the module
and its hs-boot file
Main module: type role T2 representational nominal
data Eq b => T2 a b = T2 a
Boot file: type role T2 nominal representational
Boot file: type role T2 nominal phantom
data Eq a => T2 a b = T2 a
The roles do not match. Roles default to ‘representational’ in boot files
The roles do not match.
Roles on abstract types default to ‘representational’ in boot files.
The datatype contexts do not match
RnFail055.hs-boot:16:11:
RnFail055.hs-boot:16:11: error:
‘T3’ is exported by the hs-boot file, but not exported by the module
RnFail055.hs-boot:17:12:
RnFail055.hs-boot:17:12: error:
‘T3'’ is exported by the hs-boot file, but not exported by the module
RnFail055.hs-boot:21:1:
RnFail055.hs-boot:21:1: error:
Type constructor ‘T5’ has conflicting definitions in the module
and its hs-boot file
Main module: data T5 a = T5 {field5 :: a}
......@@ -57,7 +59,7 @@ RnFail055.hs-boot:21:1:
The constructors do not match:
The record label lists for ‘T5’ differ
RnFail055.hs-boot:23:1:
RnFail055.hs-boot:23:1: error:
Type constructor ‘T6’ has conflicting definitions in the module
and its hs-boot file
Main module: data T6 = T6 Int
......@@ -65,20 +67,21 @@ RnFail055.hs-boot:23:1:
The constructors do not match:
The strictness annotations for ‘T6’ differ
RnFail055.hs-boot:25:1:
RnFail055.hs-boot:25:1: error:
Type constructor ‘T7’ has conflicting definitions in the module
and its hs-boot file
Main module: type role T7 phantom
data T7 a where
T7 :: a1 -> T7 a
Boot file: data T7 a = T7 a
The roles do not match. Roles default to ‘representational’ in boot files
The roles do not match.
Roles on abstract types default to ‘representational’ in boot files.
The constructors do not match: The types for ‘T7’ differ
RnFail055.hs-boot:27:22:
RnFail055.hs-boot:27:22: error:
‘RnFail055.m1’ is exported by the hs-boot file, but not exported by the module
RnFail055.hs-boot:28:1:
RnFail055.hs-boot:28:1: error:
Class ‘C2’ has conflicting definitions in the module
and its hs-boot file
Main module: class C2 a b where
......@@ -88,7 +91,7 @@ RnFail055.hs-boot:28:1:
m2 :: a -> b
The methods do not match: There are different numbers of methods
RnFail055.hs-boot:29:1:
RnFail055.hs-boot:29:1: error:
Class ‘C3’ has conflicting definitions in the module
and its hs-boot file
Main module: class (Eq a, Ord a) => C3 a
......
module T9204b where
import T9204b2
data P a = P
module T9204b2 where
import {-# SOURCE #-} T9204b
......@@ -6,3 +6,4 @@ test('Roles13', only_ways('normal'), compile, ['-ddump-simpl -dsuppress-uniques'
test('Roles14', only_ways('normal'), compile, ['-ddump-tc'])
test('T8958', [normalise_fun(normalise_errmsg), only_ways('normal')], compile, ['-ddump-tc -dsuppress-uniques'])
test('T10263', normal, compile, [''])
test('T9204b', extra_clean(['T9204b.o-boot', 'T9204b.hi-boot', 'T9204b2.hi', 'T9204b2.o']), multimod_compile, ['T9204b', '-v0'])
Roles12.hs:5:1:
Roles12.hs:5:1: error:
Type constructor ‘T’ has conflicting definitions in the module
and its hs-boot file
Main module: type role T phantom
data T a
Boot file: abstract T a
The roles do not match. Roles default to ‘representational’ in boot files
The roles do not match.
Roles on abstract types default to ‘representational’ in boot files.
T9204.hs:6:1:
T9204.hs:6:1: error:
Type constructor ‘D’ has conflicting definitions in the module
and its hs-boot file
Main module: type role D phantom
data D a
Boot file: abstract D a
The roles do not match. Roles default to ‘representational’ in boot files
The roles do not match.
Roles on abstract types default to ‘representational’ in boot files.
[1 of 1] Compiling ShouldFail[sig of Prelude] ( tcfail220.hsig, nothing )
tcfail220.hsig:4:1:
tcfail220.hsig:4:1: error:
Type constructor ‘Bool’ has conflicting definitions in the module
and its hsig file
Main module: data Bool = False | True
Hsig file: data Bool a b c d = False
Hsig file: type role Bool phantom phantom phantom phantom
data Bool a b c d = False
The types have different kinds
tcfail220.hsig:5:1:
tcfail220.hsig:5:1: error:
Type constructor ‘Maybe’ has conflicting definitions in the module
and its hsig file
Main module: data Maybe a = Nothing | Just a
Hsig file: data Maybe a b = Nothing
Hsig file: type role Maybe phantom phantom
data Maybe a b = Nothing
The types have different kinds
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