From 8262c954ac3084f0dfcb6d5fa6e6172afd22eae7 Mon Sep 17 00:00:00 2001 From: Thomas Miedema Date: Sun, 8 Nov 2015 00:20:15 +0100 Subject: [PATCH] Parser: allow empty multi-line deprecation warnings This should work, {-# DEPRECATED someFunction [] #-} Test Plan: parser/should_compile/T3303 Reviewers: bgamari, austin Reviewed By: austin Subscribers: mpickering Differential Revision: https://phabricator.haskell.org/D1433 GHC Trac Issues: #11044 --- compiler/parser/Parser.y | 1 + testsuite/tests/parser/should_compile/T3303.hs | 2 ++ testsuite/tests/parser/should_compile/T3303.stderr | 5 ++++- testsuite/tests/parser/should_compile/T3303A.hs | 5 +++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y index 62d1114ae4..d72f50d871 100644 --- a/compiler/parser/Parser.y +++ b/compiler/parser/Parser.y @@ -1422,6 +1422,7 @@ stringlist :: { Located (OrdList (Located StringLiteral)) } return (sLL $1 $> (unLoc $1 `snocOL` (L (gl $3) (getStringLiteral $3)))) } | STRING { sLL $1 $> (unitOL (L (gl $1) (getStringLiteral $1))) } + | {- empty -} { noLoc nilOL } ----------------------------------------------------------------------------- -- Annotations diff --git a/testsuite/tests/parser/should_compile/T3303.hs b/testsuite/tests/parser/should_compile/T3303.hs index 08de52e6cd..7d9bfbd640 100644 --- a/testsuite/tests/parser/should_compile/T3303.hs +++ b/testsuite/tests/parser/should_compile/T3303.hs @@ -6,3 +6,5 @@ import T3303A bar :: Int bar = foo +bar2 :: Int +bar2 = foo2 diff --git a/testsuite/tests/parser/should_compile/T3303.stderr b/testsuite/tests/parser/should_compile/T3303.stderr index df227f47ef..a8d2f631cf 100644 --- a/testsuite/tests/parser/should_compile/T3303.stderr +++ b/testsuite/tests/parser/should_compile/T3303.stderr @@ -1,6 +1,9 @@ -T3303.hs:7:7: Warning: +T3303.hs:7:7: warning: In the use of ‘foo’ (imported from T3303A): Deprecated: "This is a multi-line deprecation message for foo" + +T3303.hs:10:8: warning: + In the use of ‘foo2’ (imported from T3303A): Deprecated: "" diff --git a/testsuite/tests/parser/should_compile/T3303A.hs b/testsuite/tests/parser/should_compile/T3303A.hs index daa4bfb91d..07a2eb8503 100644 --- a/testsuite/tests/parser/should_compile/T3303A.hs +++ b/testsuite/tests/parser/should_compile/T3303A.hs @@ -8,3 +8,8 @@ module T3303A where foo :: Int foo = 4 +-- Empty list should work too (#11044). +{-# DEPRECATED foo2 [] #-} + +foo2 :: Int +foo2 = 4 -- GitLab