Document -fwarn-missing-import-lists
authorsimonpj@microsoft.com <unknown>
Sun, 6 Mar 2011 00:02:16 +0000 (00:02 +0000)
committersimonpj@microsoft.com <unknown>
Sun, 6 Mar 2011 00:02:16 +0000 (00:02 +0000)
Also change the behaviour slightly, to warn only for
*unqualified* imports.  See Trac #4977.

compiler/rename/RnNames.lhs
docs/users_guide/using.xml

index a756c7f..3a20ac4 100644 (file)
@@ -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 _
index 34f769a..cc5045e 100644 (file)
@@ -1300,6 +1300,36 @@ f foo = foo { x = 6 }
       </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>
          <indexterm><primary><option>-fwarn-missing-methods</option></primary></indexterm>