Allow constraints in any position in data-deps. (#10049)

This fixes #8411. It turns out the issue was some missing parentheses.

changelog_begin
changelog_end
This commit is contained in:
Sofia Faro 2021-06-17 15:45:10 +01:00 committed by GitHub
parent 7dfa36fccd
commit 2f5186938e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -776,7 +776,7 @@ convType env reexported =
ty1' <- convTypeLiftingConstraintTuples ty1
ty2' <- convType env reexported ty2
pure $ if isConstraint ty1
then HsQualTy noExt (noLoc [noLoc ty1']) (noLoc ty2')
then HsParTy noExt (noLoc $ HsQualTy noExt (noLoc [noLoc ty1']) (noLoc ty2'))
else HsParTy noExt (noLoc $ HsFunTy noExt (noLoc ty1') (noLoc ty2'))
LF.TSynApp (rewriteClassReexport env reexported -> LF.Qualified{..}) lfArgs -> do

View File

@ -327,6 +327,28 @@ tests Tools{damlc,repl,validate,davlDar,oldProjDar} = testGroup "Data Dependenci
, "x = lensIdentity"
]
-- regression for https://github.com/digital-asset/daml/issues/8411
, simpleImportTest "constraints in general position"
[ "module Lib where"
, "grantShowInt1 : (forall t. Show t => t -> Text) -> Text"
, "grantShowInt1 f = f 10"
, "grantShowInt2 : (Show Int => Int -> Text) -> Text"
, "grantShowInt2 f = f 10"
, "class Action1 m where"
, " action1 : forall e t. Action e => (Action (m e) => m e t) -> m e t"
]
[ "module Main where"
, "import Lib"
, "use1 = grantShowInt1 show"
, "use2 = grantShowInt2 show"
, "newtype M a b = M { unM : a b }"
, " deriving (Functor, Applicative, Action)"
, "instance Action1 M where"
, " action1 m = m"
, "pure1 : (Action1 m, Action e) => t -> m e t"
, "pure1 x = action1 (pure x)"
]
, testCaseSteps "Colliding package names" $ \step -> withTempDir $ \tmpDir -> do
forM_ ["1", "2"] $ \version -> do
step ("Building 'lib" <> version <> "'")