Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Alex D
GHC
Commits
32dc7698
Commit
32dc7698
authored
Oct 05, 2020
by
Krzysztof Gogolewski
Committed by
Marge Bot
Oct 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Linear types: fix roles in GADTs (#18799)
parent
36787bba
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
2 deletions
+21
-2
compiler/GHC/Tc/TyCl/Utils.hs
compiler/GHC/Tc/TyCl/Utils.hs
+2
-2
testsuite/tests/linear/should_fail/LinearRole.hs
testsuite/tests/linear/should_fail/LinearRole.hs
+12
-0
testsuite/tests/linear/should_fail/LinearRole.stderr
testsuite/tests/linear/should_fail/LinearRole.stderr
+6
-0
testsuite/tests/linear/should_fail/all.T
testsuite/tests/linear/should_fail/all.T
+1
-0
No files found.
compiler/GHC/Tc/TyCl/Utils.hs
View file @
32dc7698
...
...
@@ -580,8 +580,8 @@ irDataCon :: DataCon -> RoleM ()
irDataCon
datacon
=
setRoleInferenceVars
univ_tvs
$
irExTyVars
ex_tvs
$
\
ex_var_set
->
mapM_
(
irType
ex_var_set
)
(
map
tyVarKind
ex_tvs
++
eqSpecPreds
eq_spec
++
theta
++
(
map
scaledThing
arg_tys
)
)
do
mapM_
(
irType
ex_var_set
)
(
eqSpecPreds
eq_spec
++
theta
++
map
scaledThing
arg_tys
)
mapM_
(
markNominal
ex_var_set
)
(
map
tyVarKind
ex_tvs
++
map
scaledMult
arg_tys
)
-- Field multiplicities are nominal (#18799
)
-- See Note [Role-checking data constructor arguments]
where
(
univ_tvs
,
ex_tvs
,
eq_spec
,
theta
,
arg_tys
,
_res_ty
)
...
...
testsuite/tests/linear/should_fail/LinearRole.hs
0 → 100644
View file @
32dc7698
{-# LANGUAGE LinearTypes, GADTs, DataKinds #-}
module
LinearRole
where
-- #18799
import
GHC.Types
(
Multiplicity
(
..
))
import
Data.Coerce
data
T
m
a
where
MkT
::
a
%
m
->
T
m
a
f
::
T
'One
a
->
T
'Many
a
f
x
=
coerce
x
testsuite/tests/linear/should_fail/LinearRole.stderr
0 → 100644
View file @
32dc7698
LinearRole.hs:12:7: error:
• Couldn't match type ‘'One’ with ‘'Many’
arising from a use of ‘coerce’
• In the expression: coerce x
In an equation for ‘f’: f x = coerce x
testsuite/tests/linear/should_fail/all.T
View file @
32dc7698
...
...
@@ -17,6 +17,7 @@ test('LinearSeq', normal, compile_fail, [''])
test
('
LinearViewPattern
',
normal
,
compile_fail
,
[''])
test
('
LinearConfusedDollar
',
normal
,
compile_fail
,
[''])
test
('
LinearPatSyn
',
normal
,
compile_fail
,
[''])
test
('
LinearRole
',
normal
,
compile_fail
,
[''])
test
('
LinearGADTNewtype
',
normal
,
compile_fail
,
[''])
test
('
LinearPartialSig
',
normal
,
compile_fail
,
[''])
test
('
LinearKind
',
normal
,
compile_fail
,
[''])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment