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

Fix #9220 by adding role annotations.

This includes a submodule update for `array`.
There is also an added test in libraries/array/tests/T9220.
parent 5a8ae60e
Subproject commit 19b7aebd7dff912728029778749aaa8a9ed1cffd
Subproject commit 4baaf0b6d1e7498f529e41eaa3a065cfa84b078c
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE NoImplicitPrelude, MagicHash, UnboxedTuples #-}
{-# LANGUAGE NoImplicitPrelude, MagicHash, UnboxedTuples, RoleAnnotations #-}
{-# OPTIONS_HADDOCK hide #-}
-----------------------------------------------------------------------------
......@@ -385,6 +385,10 @@ data STArray s i e
-- No Ix context for STArray. They are stupid,
-- and force an Ix context on the equality instance.
-- Index types should have nominal role, because of Ix class. See also #9220.
type role Array nominal representational
type role STArray nominal nominal representational
-- Just pointer equality on mutable arrays:
instance Eq (STArray s i e) where
STArray _ _ _ arr1# == STArray _ _ _ arr2# =
......
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE NoImplicitPrelude, AutoDeriveTypeable #-}
{-# LANGUAGE NoImplicitPrelude, AutoDeriveTypeable, RoleAnnotations #-}
{-# OPTIONS_GHC -funbox-strict-fields #-}
{-# OPTIONS_HADDOCK hide #-}
......@@ -41,6 +41,9 @@ import Data.Typeable.Internal
newtype IOArray i e = IOArray (STArray RealWorld i e) deriving( Typeable )
-- index type should have a nominal role due to Ix class. See also #9220.
type role IOArray nominal representational
-- explicit instance because Haddock can't figure out a derived one
instance Eq (IOArray i e) where
IOArray x == IOArray y = x == y
......
......@@ -4,5 +4,4 @@ test('Roles3', only_ways('normal'), compile, ['-ddump-tc'])
test('Roles4', only_ways('normal'), compile, ['-ddump-tc'])
test('Roles13', only_ways('normal'), compile, ['-ddump-simpl -dsuppress-uniques'])
test('Roles14', only_ways('normal'), compile, ['-ddump-tc'])
test('RolesIArray', only_ways('normal'), compile, [''])
test('T8958', [normalise_fun(normalise_errmsg), only_ways('normal')], compile, ['-ddump-tc -dsuppress-uniques'])
RolesIArray.hs:10:13:
Could not coerce from ‘UArray i Word64’ to ‘UArray i N’
because the second type argument of ‘UArray’ has role Nominal,
but the arguments ‘Word64’ and ‘N’ differ
arising from the coercion of the method ‘Data.Array.Base.unsafeAccumArray’
from type ‘forall e' i.
Ix i =>
(Word64 -> e' -> Word64)
-> Word64 -> (i, i) -> [(Int, e')] -> UArray i Word64’
to type ‘forall e' i.
Ix i =>
(N -> e' -> N) -> N -> (i, i) -> [(Int, e')] -> UArray i N’
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
When deriving the instance for (IArray UArray N)
RolesIArray.hs:10:13:
Could not coerce from ‘UArray i Word64’ to ‘UArray i N’
because the second type argument of ‘UArray’ has role Nominal,
but the arguments ‘Word64’ and ‘N’ differ
arising from the coercion of the method ‘Data.Array.Base.unsafeAccum’
from type ‘forall e' i.
Ix i =>
(Word64 -> e' -> Word64)
-> UArray i Word64 -> [(Int, e')] -> UArray i Word64’
to type ‘forall e' i.
Ix i =>
(N -> e' -> N) -> UArray i N -> [(Int, e')] -> UArray i N’
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
When deriving the instance for (IArray UArray N)
RolesIArray.hs:10:13:
Could not coerce from ‘UArray i Word64’ to ‘UArray i N’
because the second type argument of ‘UArray’ has role Nominal,
but the arguments ‘Word64’ and ‘N’ differ
arising from the coercion of the method ‘Data.Array.Base.unsafeReplace’
from type ‘forall i.
Ix i =>
UArray i Word64 -> [(Int, Word64)] -> UArray i Word64’
to type ‘forall i.
Ix i =>
UArray i N -> [(Int, N)] -> UArray i N’
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
When deriving the instance for (IArray UArray N)
RolesIArray.hs:10:13:
Could not coerce from ‘UArray i Word64’ to ‘UArray i N’
because the second type argument of ‘UArray’ has role Nominal,
but the arguments ‘Word64’ and ‘N’ differ
arising from the coercion of the method ‘Data.Array.Base.unsafeAt’
from type ‘forall i. Ix i => UArray i Word64 -> Int -> Word64’
to type ‘forall i. Ix i => UArray i N -> Int -> N’
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
When deriving the instance for (IArray UArray N)
RolesIArray.hs:10:13:
Could not coerce from ‘UArray i Word64’ to ‘UArray i N’
because the second type argument of ‘UArray’ has role Nominal,
but the arguments ‘Word64’ and ‘N’ differ
arising from the coercion of the method ‘Data.Array.Base.unsafeArray’
from type ‘forall i.
Ix i =>
(i, i) -> [(Int, Word64)] -> UArray i Word64’
to type ‘forall i. Ix i => (i, i) -> [(Int, N)] -> UArray i N’
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
When deriving the instance for (IArray UArray N)
RolesIArray.hs:10:13:
Could not coerce from ‘UArray i Word64’ to ‘UArray i N’
because the second type argument of ‘UArray’ has role Nominal,
but the arguments ‘Word64’ and ‘N’ differ
arising from the coercion of the method ‘Data.Array.Base.numElements’
from type ‘forall i. Ix i => UArray i Word64 -> Int’
to type ‘forall i. Ix i => UArray i N -> Int’
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
When deriving the instance for (IArray UArray N)
RolesIArray.hs:10:13:
Could not coerce from ‘UArray i Word64’ to ‘UArray i N’
because the second type argument of ‘UArray’ has role Nominal,
but the arguments ‘Word64’ and ‘N’ differ
arising from the coercion of the method ‘bounds’
from type ‘forall i. Ix i => UArray i Word64 -> (i, i)’
to type ‘forall i. Ix i => UArray i N -> (i, i)’
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
When deriving the instance for (IArray UArray N)
......@@ -10,3 +10,4 @@ test('Roles12',
test('T8773', normal, compile_fail, [''])
test('T9204', extra_clean(['T9204.o-boot', 'T9204.hi-boot']),
run_command, ['$MAKE --no-print-directory -s T9204'])
test('RolesIArray', normal, compile_fail, [''])
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