From 0361fc038e117befc3c59fcd589d640006407ed6 Mon Sep 17 00:00:00 2001 From: Alec Theriault Date: Thu, 7 Jun 2018 13:26:53 -0400 Subject: Move 'HsBangTy' out in constructor arguments When run with -haddock, a constructor argument can have both a a strictness/unpackedness annotation and a docstring. The parser binds 'HsBangTy' more tightly than 'HsDocTy', yet for constructor arguments we really need the 'HsBangTy' on the outside. This commit does this shuffling in the 'mkConDeclH98' and 'mkGadtDecl' smart constructors. Test Plan: haddockA038, haddockC038 Reviewers: bgamari, dfeuer Reviewed By: bgamari Subscribers: dfeuer, rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4727 --- testsuite/tests/haddock/should_compile_flag_haddock/all.T | 1 + .../haddock/should_compile_flag_haddock/haddockA038.hs | 14 ++++++++++++++ .../haddock/should_compile_flag_haddock/haddockA038.stderr | 7 +++++++ .../tests/haddock/should_compile_noflag_haddock/all.T | 1 + .../haddock/should_compile_noflag_haddock/haddockC038.hs | 14 ++++++++++++++ 5 files changed, 37 insertions(+) create mode 100644 testsuite/tests/haddock/should_compile_flag_haddock/haddockA038.hs create mode 100644 testsuite/tests/haddock/should_compile_flag_haddock/haddockA038.stderr create mode 100644 testsuite/tests/haddock/should_compile_noflag_haddock/haddockC038.hs (limited to 'testsuite') diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/all.T b/testsuite/tests/haddock/should_compile_flag_haddock/all.T index 90d4a55c3f..5450fcbe7f 100644 --- a/testsuite/tests/haddock/should_compile_flag_haddock/all.T +++ b/testsuite/tests/haddock/should_compile_flag_haddock/all.T @@ -42,6 +42,7 @@ test('haddockA032', normal, compile, ['-haddock -ddump-parsed']) test('haddockA035', normal, compile, ['-haddock -ddump-parsed']) test('haddockA036', normal, compile, ['-haddock -ddump-parsed']) test('haddockA037', normal, compile, ['-haddock -ddump-parsed']) +test('haddockA038', normal, compile, ['-haddock -ddump-parsed']) # The tests below this line are not duplicated in # should_compile_noflag_haddock. diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA038.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA038.hs new file mode 100644 index 0000000000..b839bdee22 --- /dev/null +++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA038.hs @@ -0,0 +1,14 @@ +module UnamedConstructorStrictFields where +-- See #15206 + +data A = A +data B = B + +data Foo = MkFoo + {-# UNPACK #-} !A -- ^ Unpacked strict field + B + +data Bar = + {-# UNPACK #-} !A -- ^ Unpacked strict field + :%% + B diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA038.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA038.stderr new file mode 100644 index 0000000000..94318efe2b --- /dev/null +++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA038.stderr @@ -0,0 +1,7 @@ + +==================== Parser ==================== +module UnamedConstructorStrictFields where +data A = A +data B = B +data Foo = MkFoo {-# UNPACK #-} !A Unpacked strict field B +data Bar = {-# UNPACK #-} !A Unpacked strict field :%% B diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/all.T b/testsuite/tests/haddock/should_compile_noflag_haddock/all.T index edb2bd0e05..4e52c2d92c 100644 --- a/testsuite/tests/haddock/should_compile_noflag_haddock/all.T +++ b/testsuite/tests/haddock/should_compile_noflag_haddock/all.T @@ -42,6 +42,7 @@ test('haddockC032', normal, compile, ['']) test('haddockC035', normal, compile, ['']) test('haddockC036', normal, compile, ['']) test('haddockC037', normal, compile, ['']) +test('haddockC038', normal, compile, ['']) # The tests below this line are not duplicated in # should_compile_flag_haddock. diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC038.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC038.hs new file mode 100644 index 0000000000..b839bdee22 --- /dev/null +++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC038.hs @@ -0,0 +1,14 @@ +module UnamedConstructorStrictFields where +-- See #15206 + +data A = A +data B = B + +data Foo = MkFoo + {-# UNPACK #-} !A -- ^ Unpacked strict field + B + +data Bar = + {-# UNPACK #-} !A -- ^ Unpacked strict field + :%% + B -- cgit v1.2.1