From 478138c03fa30c17e37d26a0a9ad76d357a6a645 Mon Sep 17 00:00:00 2001 From: Krzysztof Gogolewski Date: Mon, 8 May 2023 18:48:33 +0200 Subject: Add a test for #17284 Since !10123 we now reject this program. --- compiler/GHC/Tc/Types.hs | 2 +- testsuite/tests/typecheck/should_fail/T17284.hs | 9 +++++++++ testsuite/tests/typecheck/should_fail/T17284.stderr | 4 ++++ testsuite/tests/typecheck/should_fail/all.T | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 testsuite/tests/typecheck/should_fail/T17284.hs create mode 100644 testsuite/tests/typecheck/should_fail/T17284.stderr diff --git a/compiler/GHC/Tc/Types.hs b/compiler/GHC/Tc/Types.hs index a6bab74fc0..28668b7979 100644 --- a/compiler/GHC/Tc/Types.hs +++ b/compiler/GHC/Tc/Types.hs @@ -1592,7 +1592,7 @@ instance Outputable TcIdSigInfo where ppr (CompleteSig { sig_bndr = bndr }) = ppr bndr <+> dcolon <+> ppr (idType bndr) ppr (PartialSig { psig_name = name, psig_hs_ty = hs_ty }) - = text "psig" <+> ppr name <+> dcolon <+> ppr hs_ty + = text "[partial signature]" <+> ppr name <+> dcolon <+> ppr hs_ty instance Outputable TcIdSigInst where ppr (TISI { sig_inst_sig = sig, sig_inst_skols = skols diff --git a/testsuite/tests/typecheck/should_fail/T17284.hs b/testsuite/tests/typecheck/should_fail/T17284.hs new file mode 100644 index 0000000000..d32dce2ba0 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T17284.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE MonomorphismRestriction #-} +{-# LANGUAGE PartialTypeSignatures #-} + +module MonoPoly where + +f :: Num a => a -> _ +f x = x + y + +y = f 1 diff --git a/testsuite/tests/typecheck/should_fail/T17284.stderr b/testsuite/tests/typecheck/should_fail/T17284.stderr new file mode 100644 index 0000000000..992f147089 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T17284.stderr @@ -0,0 +1,4 @@ + +T17284.hs:6:1: error: [GHC-16675] + Overloaded signature conflicts with monomorphism restriction + [partial signature] f :: Num a => a -> _ diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T index f13dd45b08..f62ee5e355 100644 --- a/testsuite/tests/typecheck/should_fail/all.T +++ b/testsuite/tests/typecheck/should_fail/all.T @@ -681,3 +681,4 @@ test('LazyFieldsDisabled', normal, compile_fail, ['']) test('TyfamsDisabled', normal, compile_fail, ['']) test('CommonFieldResultTypeMismatch', normal, compile_fail, ['']) test('CommonFieldTypeMismatch', normal, compile_fail, ['']) +test('T17284', normal, compile_fail, ['']) -- cgit v1.2.1