From ee1161d3f2a76ee91c415164ede4edfea3c301a9 Mon Sep 17 00:00:00 2001 From: Simon Peyton Jones Date: Wed, 23 Dec 2020 16:47:16 +0000 Subject: Add regression test for #18467 --- testsuite/tests/typecheck/should_compile/T18467.hs | 12 ++++++++++++ testsuite/tests/typecheck/should_compile/T18467.stderr | 17 +++++++++++++++++ testsuite/tests/typecheck/should_compile/all.T | 2 ++ 3 files changed, 31 insertions(+) create mode 100644 testsuite/tests/typecheck/should_compile/T18467.hs create mode 100644 testsuite/tests/typecheck/should_compile/T18467.stderr 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, ['']) + -- cgit v1.2.1