summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorVladislav Zavialov <vlad.z.4096@gmail.com>2022-09-18 15:49:50 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-09-20 03:50:42 -0400
commit59fe128c37b2befb1ece4bf3f8f5c9082bd213eb (patch)
tree98a239beac6d9ce896d72ab087215f014230cf28 /testsuite
parent545ff490144ed3ddd596d2a0c01b0a16b5528f63 (diff)
downloadhaskell-59fe128c37b2befb1ece4bf3f8f5c9082bd213eb.tar.gz
Fix -Woperator-whitespace for consym (part of #19372)
Due to an oversight, the initial specification and implementation of -Woperator-whitespace focused on varsym exclusively and completely ignored consym. This meant that expressions such as "x+ y" would produce a warning, while "x:+ y" would not. The specification was corrected in ghc-proposals pull request #404, and this patch updates the implementation accordingly. Regression test included.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/parser/should_compile/T19372consym.hs15
-rw-r--r--testsuite/tests/parser/should_compile/T19372consym.stderr15
-rw-r--r--testsuite/tests/parser/should_compile/all.T1
3 files changed, 31 insertions, 0 deletions
diff --git a/testsuite/tests/parser/should_compile/T19372consym.hs b/testsuite/tests/parser/should_compile/T19372consym.hs
new file mode 100644
index 0000000000..6a8fd14d50
--- /dev/null
+++ b/testsuite/tests/parser/should_compile/T19372consym.hs
@@ -0,0 +1,15 @@
+{-# OPTIONS -Woperator-whitespace #-}
+
+module T19372consym where
+
+import Data.List.NonEmpty
+
+a_suffix = \x y -> x: y
+a_prefix = \x y -> x :y
+a_tight_infix = \x y -> x:y
+a_loose_infix = \x y -> x : y -- Only this one should be without a warning.
+
+b_suffix = \x y -> x:| y
+b_prefix = \x y -> x :|y
+b_tight_infix = \x y -> x:|y
+b_loose_infix = \x y -> x :| y -- Only this one should be without a warning.
diff --git a/testsuite/tests/parser/should_compile/T19372consym.stderr b/testsuite/tests/parser/should_compile/T19372consym.stderr
new file mode 100644
index 0000000000..f2a0998069
--- /dev/null
+++ b/testsuite/tests/parser/should_compile/T19372consym.stderr
@@ -0,0 +1,15 @@
+
+T19372consym.hs:12:26: warning: [GHC-40798] [-Woperator-whitespace]
+ The suffix use of a ‘:|’ might be repurposed as special syntax
+ by a future language extension.
+ Suggested fix: Add whitespace around ‘:|’.
+
+T19372consym.hs:13:27: warning: [GHC-40798] [-Woperator-whitespace]
+ The prefix use of a ‘:|’ might be repurposed as special syntax
+ by a future language extension.
+ Suggested fix: Add whitespace around ‘:|’.
+
+T19372consym.hs:14:26: warning: [GHC-40798] [-Woperator-whitespace]
+ The tight infix use of a ‘:|’ might be repurposed as special syntax
+ by a future language extension.
+ Suggested fix: Add whitespace around ‘:|’.
diff --git a/testsuite/tests/parser/should_compile/all.T b/testsuite/tests/parser/should_compile/all.T
index 53fd222576..5fc2a72566 100644
--- a/testsuite/tests/parser/should_compile/all.T
+++ b/testsuite/tests/parser/should_compile/all.T
@@ -193,3 +193,4 @@ test('T20718', normal, compile, ['-dsuppress-uniques -ddump-parsed-ast -dkeep-c
test('T20718b', normal, compile, ['-dsuppress-uniques -ddump-parsed-ast -dkeep-comments'])
test('T21589', normal, compile, [''])
+test('T19372consym', normal, compile, [''])