From 6738c01d6175c5701e5c53e2ae6716d1103f7355 Mon Sep 17 00:00:00 2001 From: Krzysztof Gogolewski Date: Mon, 17 Apr 2023 10:31:32 +0200 Subject: Add a regression test for #21050 --- testsuite/tests/th/T21050.hs | 11 +++++++++++ testsuite/tests/th/T21050.stderr | 26 ++++++++++++++++++++++++++ testsuite/tests/th/all.T | 1 + 3 files changed, 38 insertions(+) create mode 100644 testsuite/tests/th/T21050.hs create mode 100644 testsuite/tests/th/T21050.stderr diff --git a/testsuite/tests/th/T21050.hs b/testsuite/tests/th/T21050.hs new file mode 100644 index 0000000000..6c31b7a3f4 --- /dev/null +++ b/testsuite/tests/th/T21050.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE TemplateHaskell, ImpredicativeTypes #-} +module T21050 where + +import Language.Haskell.TH.Syntax + +data T = MkT (forall a. a) + +f x = [|| MkT $$(x) ||] + +g :: Code Q (forall a. a) -> Code Q T +g x = [|| MkT $$(x) ||] diff --git a/testsuite/tests/th/T21050.stderr b/testsuite/tests/th/T21050.stderr new file mode 100644 index 0000000000..4d2a84e274 --- /dev/null +++ b/testsuite/tests/th/T21050.stderr @@ -0,0 +1,26 @@ + +T21050.hs:8:18: error: [GHC-25897] + • Couldn't match expected type ‘Code m a1’ with actual type ‘p’ + ‘p’ is a rigid type variable bound by + the inferred type of f :: Quote m => p -> Code m T + at T21050.hs:8:1-23 + • In the expression: x + In the Template Haskell splice $$(x) + In the first argument of ‘MkT’, namely ‘$$(x)’ + • Relevant bindings include + x :: p (bound at T21050.hs:8:3) + f :: p -> Code m T (bound at T21050.hs:8:1) + +T21050.hs:11:18: error: [GHC-91028] + • Couldn't match type ‘a’ with ‘forall a2. a2’ + Expected: Code Q a + Actual: Code Q (forall a. a) + Cannot equate type variable ‘a’ + with a type involving polytypes: forall a2. a2 + ‘a’ is a rigid type variable bound by + a type expected by the context: + forall a. a + at T21050.hs:11:15-19 + • In the expression: x + In the Template Haskell splice $$(x) + In the first argument of ‘MkT’, namely ‘$$(x)’ diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T index 60f02a9c2e..3a98df38ee 100644 --- a/testsuite/tests/th/all.T +++ b/testsuite/tests/th/all.T @@ -564,3 +564,4 @@ test('TH_typed2', normal, compile_and_run, ['']) test('TH_typed3', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques']) test('TH_typed4', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques']) test('TH_typed5', normal, compile_and_run, ['']) +test('T21050', normal, compile_fail, ['']) -- cgit v1.2.1