From c8f623e305ec0a51ac2406a1f754d244e05b96f5 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Wed, 2 Sep 2015 13:57:44 +0200 Subject: Expand declaration QQs first (#10047) Declaration QuasiQuoters do not cause a group split like $(...) splices, and are run and expanded before other declarations in the group. Resolves the lingering issue with #10047, and fixes broken tests qq007 and qq008. Test Plan: validate Reviewers: goldfire, austin, bgamari Reviewed By: bgamari Subscribers: goldfire, simonpj, thomie, spinda Differential Revision: https://phabricator.haskell.org/D1199 GHC Trac Issues: #10047 --- testsuite/tests/quasiquotation/qq007/test.T | 1 - testsuite/tests/quasiquotation/qq008/test.T | 1 - testsuite/tests/quasiquotation/qq009/Makefile | 11 +++++++++++ testsuite/tests/quasiquotation/qq009/QQ.hs | 14 ++++++++++++++ testsuite/tests/quasiquotation/qq009/Test.hs | 9 +++++++++ testsuite/tests/quasiquotation/qq009/test.T | 7 +++++++ 6 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 testsuite/tests/quasiquotation/qq009/Makefile create mode 100644 testsuite/tests/quasiquotation/qq009/QQ.hs create mode 100644 testsuite/tests/quasiquotation/qq009/Test.hs create mode 100644 testsuite/tests/quasiquotation/qq009/test.T (limited to 'testsuite/tests/quasiquotation') diff --git a/testsuite/tests/quasiquotation/qq007/test.T b/testsuite/tests/quasiquotation/qq007/test.T index d9a2df31d3..0b4448cdc0 100644 --- a/testsuite/tests/quasiquotation/qq007/test.T +++ b/testsuite/tests/quasiquotation/qq007/test.T @@ -2,7 +2,6 @@ test('qq007', [when(fast(), skip), extra_clean(['QQ.hi', 'QQ.o', 'Test.hi', 'Test.o']), pre_cmd('$MAKE -s --no-print-directory TH_QQ'), - expect_broken(10047), ], multimod_compile, ['Test', '-v0']) diff --git a/testsuite/tests/quasiquotation/qq008/test.T b/testsuite/tests/quasiquotation/qq008/test.T index 5bdd2a9822..8cac1a9f0a 100644 --- a/testsuite/tests/quasiquotation/qq008/test.T +++ b/testsuite/tests/quasiquotation/qq008/test.T @@ -2,7 +2,6 @@ test('qq008', [when(fast(), skip), extra_clean(['QQ.hi', 'QQ.o', 'Test.hi', 'Test.o']), pre_cmd('$MAKE -s --no-print-directory TH_QQ'), - expect_broken(10047), ], multimod_compile, ['Test', '-v0']) diff --git a/testsuite/tests/quasiquotation/qq009/Makefile b/testsuite/tests/quasiquotation/qq009/Makefile new file mode 100644 index 0000000000..0fa91dbf9a --- /dev/null +++ b/testsuite/tests/quasiquotation/qq009/Makefile @@ -0,0 +1,11 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +.PHONY: TH_QQ +TH_QQ: +ifeq "$(GhcDynamic)" "YES" + '$(TEST_HC)' $(TEST_HC_OPTS) -c QQ.hs -dynamic -osuf dyn_o -hisuf dyn_hi +else + '$(TEST_HC)' $(TEST_HC_OPTS) -c QQ.hs +endif diff --git a/testsuite/tests/quasiquotation/qq009/QQ.hs b/testsuite/tests/quasiquotation/qq009/QQ.hs new file mode 100644 index 0000000000..89350bac60 --- /dev/null +++ b/testsuite/tests/quasiquotation/qq009/QQ.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE TemplateHaskell #-} +module QQ where + +import Language.Haskell.TH.Quote +import Language.Haskell.TH.Syntax +import Language.Haskell.TH + +pq = QuasiQuoter { quoteDec = \_ -> return [sig], + quoteType = \_ -> undefined, + quoteExp = \_ -> undefined, + quotePat = \_ -> undefined } + +sig = SigD (mkName "f") (ArrowT `AppT` int `AppT` int) +int = ConT (mkName "Int") diff --git a/testsuite/tests/quasiquotation/qq009/Test.hs b/testsuite/tests/quasiquotation/qq009/Test.hs new file mode 100644 index 0000000000..1b43fb2acf --- /dev/null +++ b/testsuite/tests/quasiquotation/qq009/Test.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE QuasiQuotes #-} +module Test where + +import QQ + +f' = f . (+ 1) + +[pq| foo |] -- Expands to f :: Int -> Int +f x = x + 1 diff --git a/testsuite/tests/quasiquotation/qq009/test.T b/testsuite/tests/quasiquotation/qq009/test.T new file mode 100644 index 0000000000..10b939a3bd --- /dev/null +++ b/testsuite/tests/quasiquotation/qq009/test.T @@ -0,0 +1,7 @@ +test('qq009', + [when(fast(), skip), + extra_clean(['QQ.hi', 'QQ.o', 'Test.hi', 'Test.o']), + pre_cmd('$MAKE -s --no-print-directory TH_QQ'), + ], + multimod_compile, + ['Test', '-v0']) -- cgit v1.2.1