Commit 4b7d8ae0 authored by simonpj@microsoft.com's avatar simonpj@microsoft.com

Document -fwarn-missing-import-lists

Also change the behaviour slightly, to warn only for
*unqualified* imports.  See Trac #4977.
parent 2db562c7
......@@ -112,8 +112,9 @@ rnImportDecl this_mod implicit_prelude
-- (Opt_WarnMissingImportList also checks for T(..) items
-- but that is done in checkDodgyImport below)
case imp_details of
Just (False, _) -> return ()
Just (False, _) -> return () -- Explicit import list
_ | implicit_prelude -> return ()
| qual_only -> return ()
| otherwise -> ifDOptM Opt_WarnMissingImportList $
addWarn (missingImportListWarn imp_mod_name)
......@@ -586,6 +587,7 @@ filterImports iface decl_spec (Just (want_hiding, import_items)) all_avails
= ifDOptM Opt_WarnDodgyImports (addWarn (dodgyImportWarn n))
-- NB. use the RdrName for reporting the warning
| IEThingAll {} <- ieRdr
, not (is_qual decl_spec)
= ifDOptM Opt_WarnMissingImportList $
addWarn (missingImportListItem ieRdr)
checkDodgyImport _
......
......@@ -1299,6 +1299,36 @@ f foo = foo { x = 6 }
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>-fwarn-missing-import-lists</option>:
<indexterm><primary><option>-fwarn-import-lists</option></primary></indexterm>
<indexterm><primary>missing import lists, warning</primary></indexterm>
<indexterm><primary>import lists, missing</primary></indexterm>
</term>
<listitem>
<para>This flag warns if you use an unqualified
<literal>import</literal> declaration
that does not explicitly list the entities brought into scope. For
example
<programlisting>
module M where
import X( f )
import Y
import qualified Z
p x = f x x
<programlisting>
The <option>-fwarn-import-lists</option> flag will warn about the import
of <literal>Y</literal> but not <literal>X</literal>
If module <literal>Y</literal> is later changed to export (say) <literal>f</literal>,
then the reference to <literal>f</literal> in <literal>M</literal> will become
ambiguous. No warning is produced for the import of <literal>Z</literal>
because extending <literal>Z</literal>'s exports would be unlikely to produce
ambiguity in <literal>M</literal>.
</listitem>
</varlistentry>
<varlistentry>
<term><option>-fwarn-missing-methods</option>:</term>
<listitem>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment