summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarrie Xu <carrie.xmy@gmail.com>2021-10-09 20:54:30 +0800
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-10-12 01:41:41 -0400
commit58223dfacc709b6c2130b8fad466f0939d9a1043 (patch)
tree3e2c334e810f14fc8c56754a377189c9a76f46c8
parent2c06720e45efaf4d3a8e957f3ea7613d1ea311a8 (diff)
downloadhaskell-58223dfacc709b6c2130b8fad466f0939d9a1043.tar.gz
Add Hint to "Empty 'do' block" Error Message#20147
-rw-r--r--compiler/GHC/Rename/Expr.hs3
-rw-r--r--testsuite/tests/rename/should_fail/T20147.hs7
-rw-r--r--testsuite/tests/rename/should_fail/T20147.stderr4
-rw-r--r--testsuite/tests/rename/should_fail/all.T1
4 files changed, 15 insertions, 0 deletions
diff --git a/compiler/GHC/Rename/Expr.hs b/compiler/GHC/Rename/Expr.hs
index c7ef4dcfbd..e1568d5e01 100644
--- a/compiler/GHC/Rename/Expr.hs
+++ b/compiler/GHC/Rename/Expr.hs
@@ -55,6 +55,7 @@ import GHC.Builtin.Names
import GHC.Types.FieldLabel
import GHC.Types.Fixity
+import GHC.Types.Hint (suggestExtension)
import GHC.Types.Id.Make
import GHC.Types.Name
import GHC.Types.Name.Set
@@ -2361,6 +2362,8 @@ emptyErr (ParStmtCtxt {}) = TcRnUnknownMessage $ mkPlainError noHints $
text "Empty statement group in parallel comprehension"
emptyErr (TransStmtCtxt {}) = TcRnUnknownMessage $ mkPlainError noHints $
text "Empty statement group preceding 'group' or 'then'"
+emptyErr ctxt@(HsDoStmt _) = TcRnUnknownMessage $ mkPlainError [suggestExtension LangExt.NondecreasingIndentation] $
+ text "Empty" <+> pprStmtContext ctxt
emptyErr ctxt = TcRnUnknownMessage $ mkPlainError noHints $
text "Empty" <+> pprStmtContext ctxt
diff --git a/testsuite/tests/rename/should_fail/T20147.hs b/testsuite/tests/rename/should_fail/T20147.hs
new file mode 100644
index 0000000000..b44717617c
--- /dev/null
+++ b/testsuite/tests/rename/should_fail/T20147.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE NoNondecreasingIndentation #-}
+module T20147 where
+
+main = do
+ print "doing things with X"
+ withFile "test" $ \h -> do
+ readFile h
diff --git a/testsuite/tests/rename/should_fail/T20147.stderr b/testsuite/tests/rename/should_fail/T20147.stderr
new file mode 100644
index 0000000000..c70d3d0a8e
--- /dev/null
+++ b/testsuite/tests/rename/should_fail/T20147.stderr
@@ -0,0 +1,4 @@
+
+T20147.hs:6:28: error:
+ Empty 'do' block
+ Suggested fix: Perhaps you intended to use NondecreasingIndentation
diff --git a/testsuite/tests/rename/should_fail/all.T b/testsuite/tests/rename/should_fail/all.T
index 6c2f0134a0..aec42ad733 100644
--- a/testsuite/tests/rename/should_fail/all.T
+++ b/testsuite/tests/rename/should_fail/all.T
@@ -179,3 +179,4 @@ test('T19843l', normal, compile_fail, [''])
test('T19843m', normal, compile_fail, [''])
test('T11167_ambig', normal, compile_fail, [''])
test('T18138', normal, compile_fail, [''])
+test('T20147', normal, compile_fail, ['']) \ No newline at end of file