@@ -3036,6 +3036,21 @@ addFunctionConstraintTests = let
3036
3036
, " eq (Pair x y) (Pair x' y') = x == x' && y == y'"
3037
3037
]
3038
3038
3039
+ -- See https://github.com/haskell/haskell-language-server/issues/4648
3040
+ -- When haddock comment appears after the =>, code action was introducing the
3041
+ -- new constraint in the comment
3042
+ incompleteConstraintSourceCodeWithCommentInTypeSignature :: T. Text -> T. Text
3043
+ incompleteConstraintSourceCodeWithCommentInTypeSignature constraint =
3044
+ T. unlines
3045
+
3046
+ [ " module Testing where"
3047
+ , " foo "
3048
+ , " :: (" <> constraint <> " ) =>"
3049
+ , " -- This is a comment"
3050
+ , " m ()"
3051
+ , " foo = pure ()"
3052
+ ]
3053
+
3039
3054
missingMonadConstraint constraint = T. unlines
3040
3055
[ " module Testing where"
3041
3056
, " f :: " <> constraint <> " m ()"
@@ -3079,6 +3094,11 @@ addFunctionConstraintTests = let
3079
3094
" Add `Eq b` to the context of the type signature for `eq`"
3080
3095
(incompleteConstraintSourceCodeWithNewlinesInTypeSignature " Eq a" )
3081
3096
(incompleteConstraintSourceCodeWithNewlinesInTypeSignature " Eq a, Eq b" )
3097
+ , checkCodeAction
3098
+ " preexisting constraint, with haddock comment in type signature"
3099
+ " Add `Applicative m` to the context of the type signature for `foo`"
3100
+ (incompleteConstraintSourceCodeWithCommentInTypeSignature " " )
3101
+ (incompleteConstraintSourceCodeWithCommentInTypeSignature " Applicative m" )
3082
3102
, checkCodeAction
3083
3103
" missing Monad constraint"
3084
3104
" Add `Monad m` to the context of the type signature for `f`"
0 commit comments