Avoid panic due to partial ieName
authorEric Seidel <gridaphobe@gmail.com>
Wed, 2 Dec 2015 20:37:21 +0000 (14:37 -0600)
committerAustin Seipp <austin@well-typed.com>
Wed, 2 Dec 2015 20:38:58 +0000 (14:38 -0600)
HsImpExp.ieName is partial and fails when given e.g. `module X`

solution: use ieNames instead which returns a list of names instead of a single name.

Reviewed By: bgamari, austin

Differential Revision: https://phabricator.haskell.org/D1551

GHC Trac Issues: #11077

compiler/typecheck/TcHsSyn.hs
testsuite/tests/warnings/should_compile/T11077.hs [new file with mode: 0644]
testsuite/tests/warnings/should_compile/T11077.stderr [new file with mode: 0644]
testsuite/tests/warnings/should_compile/all.T

index ae095e0..39e7f2d 100644 (file)
@@ -317,7 +317,7 @@ zonkTopDecls ev_binds binds export_ies sig_ns rules vects imp_specs fords
         ; warn_missing_sigs <- woptM Opt_WarnMissingSigs
         ; warn_only_exported <- woptM Opt_WarnMissingExportedSigs
         ; let export_occs  = maybe emptyBag
-                                   (listToBag . map (rdrNameOcc . ieName . unLoc) . unLoc)
+                                   (listToBag . concatMap (map rdrNameOcc . ieNames . unLoc) . unLoc)
                                    export_ies
               sig_warn
                 | warn_only_exported = topSigWarnIfExported export_occs sig_ns
diff --git a/testsuite/tests/warnings/should_compile/T11077.hs b/testsuite/tests/warnings/should_compile/T11077.hs
new file mode 100644 (file)
index 0000000..76533cb
--- /dev/null
@@ -0,0 +1,3 @@
+module T11077 (module X, foo) where
+import Data.List as X
+foo = undefined
diff --git a/testsuite/tests/warnings/should_compile/T11077.stderr b/testsuite/tests/warnings/should_compile/T11077.stderr
new file mode 100644 (file)
index 0000000..3cb2cba
--- /dev/null
@@ -0,0 +1,3 @@
+
+T11077.hs:3:1: warning:
+    Top-level binding with no type signature: foo :: forall t. t
index 3954ba8..c2b8dd2 100644 (file)
@@ -4,6 +4,7 @@ test('T9178', extra_clean(['T9178.o', 'T9178DataType.o',
                           'T9178.hi', 'T9178DataType.hi']),
              multimod_compile, ['T9178', '-Wall'])
 test('T9230', normal, compile_without_flag('-fno-warn-tabs'), [''])
+test('T11077', normal, compile, ['-fwarn-missing-exported-sigs'])
 test('T11128', normal, compile, [''])
 
 test('DeprU',