summaryrefslogtreecommitdiff
path: root/testsuite/tests/parser
diff options
context:
space:
mode:
authorVladislav Zavialov <vlad.z.4096@gmail.com>2020-10-13 02:39:12 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-10-19 18:16:20 -0400
commitb5b3e34ec39fc89a0bcd0b60cf9a4962c89ba72f (patch)
tree82f4f5360a5450d5e86fb9e0204af7b4712ae26b /testsuite/tests/parser
parentd858a3aebee5adc447556b668b65b6e46370d8c0 (diff)
downloadhaskell-b5b3e34ec39fc89a0bcd0b60cf9a4962c89ba72f.tar.gz
Implement -Woperator-whitespace (#18834)
This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers.
Diffstat (limited to 'testsuite/tests/parser')
-rw-r--r--testsuite/tests/parser/should_compile/T18834a.hs8
-rw-r--r--testsuite/tests/parser/should_compile/T18834a.stderr15
-rw-r--r--testsuite/tests/parser/should_compile/T18834b.hs8
-rw-r--r--testsuite/tests/parser/should_compile/T18834b.stderr15
-rw-r--r--testsuite/tests/parser/should_compile/all.T2
5 files changed, 48 insertions, 0 deletions
diff --git a/testsuite/tests/parser/should_compile/T18834a.hs b/testsuite/tests/parser/should_compile/T18834a.hs
new file mode 100644
index 0000000000..7666173d20
--- /dev/null
+++ b/testsuite/tests/parser/should_compile/T18834a.hs
@@ -0,0 +1,8 @@
+module T18834a where
+
+(%) = ($)
+($$) = ($)
+
+x = even $0
+y = even $$0
+z = even %0
diff --git a/testsuite/tests/parser/should_compile/T18834a.stderr b/testsuite/tests/parser/should_compile/T18834a.stderr
new file mode 100644
index 0000000000..2fd8f5903d
--- /dev/null
+++ b/testsuite/tests/parser/should_compile/T18834a.stderr
@@ -0,0 +1,15 @@
+
+T18834a.hs:6:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)]
+ The prefix use of a ‘$’ would denote an untyped splice
+ were the TemplateHaskell extension enabled.
+ Suggested fix: add whitespace after the ‘$’.
+
+T18834a.hs:7:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)]
+ The prefix use of a ‘$$’ would denote a typed splice
+ were the TemplateHaskell extension enabled.
+ Suggested fix: add whitespace after the ‘$$’.
+
+T18834a.hs:8:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)]
+ The prefix use of a ‘%’ would denote a multiplicity annotation
+ were the LinearTypes extension enabled.
+ Suggested fix: add whitespace after the ‘%’.
diff --git a/testsuite/tests/parser/should_compile/T18834b.hs b/testsuite/tests/parser/should_compile/T18834b.hs
new file mode 100644
index 0000000000..8a020b8b5f
--- /dev/null
+++ b/testsuite/tests/parser/should_compile/T18834b.hs
@@ -0,0 +1,8 @@
+{-# OPTIONS -Woperator-whitespace #-}
+
+module T18834b where
+
+f a b = a+ b
+g a b = a +b
+h a b = a+b
+k a b = a + b -- this one is OK, no warning
diff --git a/testsuite/tests/parser/should_compile/T18834b.stderr b/testsuite/tests/parser/should_compile/T18834b.stderr
new file mode 100644
index 0000000000..9ec4f81bb4
--- /dev/null
+++ b/testsuite/tests/parser/should_compile/T18834b.stderr
@@ -0,0 +1,15 @@
+
+T18834b.hs:5:10: warning: [-Woperator-whitespace]
+ The suffix use of a ‘+’ might be repurposed as special syntax
+ by a future language extension.
+ Suggested fix: add whitespace around it.
+
+T18834b.hs:6:11: warning: [-Woperator-whitespace]
+ The prefix use of a ‘+’ might be repurposed as special syntax
+ by a future language extension.
+ Suggested fix: add whitespace around it.
+
+T18834b.hs:7:10: warning: [-Woperator-whitespace]
+ The tight infix use of a ‘+’ might be repurposed as special syntax
+ by a future language extension.
+ Suggested fix: add whitespace around it.
diff --git a/testsuite/tests/parser/should_compile/all.T b/testsuite/tests/parser/should_compile/all.T
index 48e1136daa..f63a3f95d9 100644
--- a/testsuite/tests/parser/should_compile/all.T
+++ b/testsuite/tests/parser/should_compile/all.T
@@ -170,3 +170,5 @@ test('proposal-229f',
test('T15730a', normal, compile_and_run, [''])
test('T18130', normal, compile, [''])
+test('T18834a', normal, compile, [''])
+test('T18834b', normal, compile, [''])