summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2020-12-23 16:47:16 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2021-01-02 14:13:25 +0000
commitee1161d3f2a76ee91c415164ede4edfea3c301a9 (patch)
tree57726bec52fe71131c3626b9cf257b94080d9fb8
parenta8926e951eed83a34d39ddaad409ba685b21b38a (diff)
downloadhaskell-ee1161d3f2a76ee91c415164ede4edfea3c301a9.tar.gz
Add regression test for #18467wip/T18467
-rw-r--r--testsuite/tests/typecheck/should_compile/T18467.hs12
-rw-r--r--testsuite/tests/typecheck/should_compile/T18467.stderr17
-rw-r--r--testsuite/tests/typecheck/should_compile/all.T2
3 files changed, 31 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_compile/T18467.hs b/testsuite/tests/typecheck/should_compile/T18467.hs
new file mode 100644
index 0000000000..b105edf3d8
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T18467.hs
@@ -0,0 +1,12 @@
+{-# OPTIONS_GHC -fdefer-type-errors #-}
+
+module T18467 where
+
+----------------------
+x = 3 -- Monomorphism restriction; we get x::alpha
+
+f y = x::Float
+g z = x::Int
+
+-------------
+h v = let t = \y -> (v, y : y) in fst (t True)
diff --git a/testsuite/tests/typecheck/should_compile/T18467.stderr b/testsuite/tests/typecheck/should_compile/T18467.stderr
new file mode 100644
index 0000000000..7ebf51de6f
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T18467.stderr
@@ -0,0 +1,17 @@
+
+T18467.hs:9:7: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match expected type ‘Int’ with actual type ‘Float’
+ • In the expression: x :: Int
+ In an equation for ‘g’: g z = x :: Int
+
+T18467.hs:12:29: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match expected type ‘[a1]’ with actual type ‘a1’
+ ‘a1’ is a rigid type variable bound by
+ the inferred type of t :: a1 -> (a, [a1])
+ at T18467.hs:12:11-30
+ • In the second argument of ‘(:)’, namely ‘y’
+ In the expression: y : y
+ In the expression: (v, y : y)
+ • Relevant bindings include
+ y :: a1 (bound at T18467.hs:12:16)
+ t :: a1 -> (a, [a1]) (bound at T18467.hs:12:11)
diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T
index da663d484b..a461ed7257 100644
--- a/testsuite/tests/typecheck/should_compile/all.T
+++ b/testsuite/tests/typecheck/should_compile/all.T
@@ -764,3 +764,5 @@ test('InlinePatSyn_NoInlineBuilder', [], makefile_test, [])
test('InlinePatSyn_NoInlineMatcher', [], makefile_test, [])
test('InlinePatSyn_ExplicitBidiBuilder', [], makefile_test, [])
test('InlinePatSyn_ExplicitBidiMatcher', [], makefile_test, [])
+test('T18467', normal, compile, [''])
+