Skip to content

Commit dcd4d82

Browse files
committed
Add -compile({no_auto_import,[F/A]}) doc to compiler.xml
1 parent b72cac2 commit dcd4d82

File tree

1 file changed

+56
-18
lines changed

1 file changed

+56
-18
lines changed

lib/compiler/doc/src/compile.xml

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,23 @@
310310
(there will not even be a warning if there is a mismatch).</p>
311311
</item>
312312

313+
<tag><c>{no_auto_import,[F/A, ...]}</c></tag>
314+
<item>
315+
<p>Makes the function <c>F/A</c> no longer beeing
316+
auto-imported from the module <c>erlang</c>, which resolves
317+
BIF name clashes. This option has to be used to resolve name
318+
clashes with BIFs auto-imported before R14A, if one wants to
319+
call the local function with the same name as an
320+
auto-imported BIF without module prefix.</p>
321+
<note>
322+
<p>From R14A and forward, the compiler resolves calls
323+
without module prefix to local or imported functions before
324+
trying auto-imported BIFs. If the BIF is to be
325+
called, use the <c>erlang</c> module prefix in the call, not
326+
<c>{ no_auto_import,[F/A, ...]}</c></p>
327+
</note>
328+
</item>
329+
313330
</taglist>
314331

315332
<p>If warnings are turned on (the <c>report_warnings</c> option
@@ -338,31 +355,52 @@
338355

339356
<tag><c>nowarn_bif_clash</c></tag>
340357
<item>
341-
<p>By default, there will be a compilation error if a
342-
module contains an exported function with the same name
343-
as an auto-imported BIF (such as <c>size/1</c>) AND
344-
there is a call to it without a qualifying module name.
345-
The reason is that the BIF will be called, not
346-
the function in the same module. The recommended way to
347-
eliminate that warning is to use a call with a module
348-
name - either <c>erlang</c> to call the BIF or
349-
<c>?MODULE</c> to call the function in the same module.
350-
The warning can also be turned off using this option,
351-
but that is not recommended.</p>
352-
353-
<p><em>The use of this option is strongly discouraged,
354-
as code that uses it will probably break in a future
355-
major release (R14 or R15).</em></p>
358+
<p>By default, the compiler will issue an error or warning
359+
when replacing an auto-imported BIF. For local functions
360+
having names clashing with an auto-imported BIF, the error
361+
or warning is issued whenever it is called without using a
362+
module prefix. For explicitly imported functions, the
363+
error or warning will be issued as soon as it's imported
364+
(regardless of calls). If the auto-imported BIF was present
365+
before OTP R14A it will be a fatal error to override it,
366+
otherwise only a warning will be issued.</p>
367+
368+
<warning>
369+
<p>Beginning with R14A, the compiler no longer calls the
370+
auto-imported BIF if the name clashes with a local or
371+
explicitly imported function and a call without explicit
372+
module name is issued. Instead the local or imported
373+
function is called. Use of <c>nowarn_bif_clash</c> makes a
374+
module calling functions clashing with autoimported BIFs
375+
compile with both the old and new compilers, but with
376+
completely different semantics, why a warning is always
377+
issued if any code uses this option.</p>
378+
379+
<p>The use of this option has always been strongly discouraged.
380+
From OTP R14A and forward it's also deprecated.</p>
381+
<p>The only module who actually could have some legitimate use for
382+
this option is the module <c>erlang</c>, which in
383+
itself contains auto-imported functions, other modules
384+
should never use it.</p>
385+
<p>To resolve BIF clashes, use explicit module names or the
386+
<c>{no_auto_import,[F/A]}</c> directive.</p>
387+
<p><c>nowarn_bif_clash</c> <em>will</em> be removed in a future release.</p>
388+
</warning>
356389
</item>
357390

358391
<tag><c>{nowarn_bif_clash, FAs}</c></tag>
359392
<item>
360393
<p>Turns off warnings as <c>nowarn_bif_clash</c> but only
361394
for the mentioned local functions. <c>FAs</c> is a tuple
362395
<c>{Name,Arity}</c> or a list of such tuples.</p>
363-
<p><em>The use of this option is strongly discouraged,
364-
as code that uses it will probably break in a future
365-
major release (R14 or R15).</em></p>
396+
<warning>
397+
<p>The use of this option has always been strongly discouraged.
398+
From OTP R14A and forward it's also deprecated and a warning will be issued
399+
whenever it is used.</p>
400+
<p>To resolve BIF clashes, use explicit module names or the
401+
<c>{no_auto_import,[F/A]}</c> directive instead.</p>
402+
<p><c>nowarn_bif_clash</c> <em>will</em> be removed in a future release.</p>
403+
</warning>
366404
</item>
367405

368406
<tag><c>warn_export_all</c></tag>

0 commit comments

Comments
 (0)