From 33fa8d9433d82b03f3209698bf27420a32302321 Mon Sep 17 00:00:00 2001 From: Ryan Scott Date: Wed, 19 Feb 2020 17:06:59 -0500 Subject: Generalize liftData to work over any Quote (#17857) The Overloaded Quotations proposal generalized the type of `lift` to work over any `Quote`, but not the type of `liftData`, leading to #17857. Thankfully, generalizing `liftData` is extremely straightforward. Fixes #17857. --- testsuite/tests/quotes/T17857.hs | 10 ++++++++++ testsuite/tests/quotes/all.T | 1 + testsuite/tests/th/T10796b.stderr | 8 ++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 testsuite/tests/quotes/T17857.hs (limited to 'testsuite') diff --git a/testsuite/tests/quotes/T17857.hs b/testsuite/tests/quotes/T17857.hs new file mode 100644 index 0000000000..f64f0ce753 --- /dev/null +++ b/testsuite/tests/quotes/T17857.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE DeriveDataTypeable #-} +module T17857 where + +import Data.Data +import Language.Haskell.TH.Syntax + +data T = MkT deriving Data +instance Lift T where + lift = liftData + liftTyped = unsafeTExpCoerce . lift diff --git a/testsuite/tests/quotes/all.T b/testsuite/tests/quotes/all.T index 46f53bce6a..1a5d5242b4 100644 --- a/testsuite/tests/quotes/all.T +++ b/testsuite/tests/quotes/all.T @@ -16,6 +16,7 @@ test('T8759a', normal, compile, ['-v0']) test('T9824', normal, compile, ['-v0']) test('T10384', normal, compile_fail, ['']) test('T16384', req_th, compile, ['']) +test('T17857', normal, compile, ['']) test('TH_tf2', normal, compile, ['-v0']) test('TH_ppr1', normal, compile_and_run, ['']) diff --git a/testsuite/tests/th/T10796b.stderr b/testsuite/tests/th/T10796b.stderr index 7c7b89171b..84a03ddc86 100644 --- a/testsuite/tests/th/T10796b.stderr +++ b/testsuite/tests/th/T10796b.stderr @@ -1,5 +1,9 @@ -T10796b.hs:8:16: error: - • Can't construct a pattern from name Data.Set.Internal.fromList +T10796b.hs:8:15: error: + • Exception when trying to run compile-time code: + Can't construct a pattern from name Data.Set.Internal.fromList +CallStack (from HasCallStack): + error, called at libraries/template-haskell/Language/Haskell/TH/Syntax.hs:1203:22 in template-haskell:Language.Haskell.TH.Syntax + Code: (dataToPatQ (const Nothing) (fromList "test")) • In the untyped splice: $(dataToPatQ (const Nothing) (fromList "test")) -- cgit v1.2.1