20042013 Ericsson AB. All Rights Reserved. The contents of this file are subject to the Erlang Public License, Version 1.1, (the "License"); you may not use this file except in compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Compiler Release Notes otp_appnotes nil nil nil notes.xml

This document describes the changes made to the Compiler application.

Compiler 5.0
Fixed Bugs and Malfunctions

Line numbers would not be correct when a binary construction such as '<<Bin/binary,...>>' fails. (Thanks to Stanislav Seletskiy for reporting this bug.)

Own Id: OTP-11572

The compiler now properly annotates the code in value in the 'after' clause for a 'try' so that Dialyzer no longer generates a false warning for an unmatched return.

Own Id: OTP-11580

Some case statements where no clause would match could cause an internal error in the compiler. (Thanks to Erik Soe Sorensen for reporting this bug.)

Own Id: OTP-11610

With --Wunmatched_returns, dialyzer will no longer warn when the value of a list comprehension is ignored, provided that the each value in the list would be an atomic value (such as integer or atoms, as opposed to tuples and lists). Example: ignoring '[io:format(...) || ...]' will not cause a warning, while ignoring '[file:close(Fd) || ...]' will.

Own Id: OTP-11626

Matching out a binary and applying the binary as if it were a fun would crash the run-time system. (Thanks to Loïc Hoguin.)

Own Id: OTP-11672

Some local implementations of removing the last element from a list are replaced by lists:droplast/1. Note that this requires at least stdlib-2.0, which is the stdlib version delivered in OTP 17.0. (Thanks to Hans Svensson)

Own Id: OTP-11678

Allow all auto imports to be suppressed at once. Introducing the no_auto_import attribute: -compile(no_auto_import). Useful for code generation tools that always use the qualified function names and want to avoid the auto imported functions clashing with local ones. (Thanks to José Valim.)

Own Id: OTP-11682

Application upgrade (appup) files are corrected for the following applications:

asn1, common_test, compiler, crypto, debugger, dialyzer, edoc, eldap, erl_docgen, et, eunit, gs, hipe, inets, observer, odbc, os_mon, otp_mibs, parsetools, percept, public_key, reltool, runtime_tools, ssh, syntax_tools, test_server, tools, typer, webtool, wx, xmerl

A new test utility for testing appup files is added to test_server. This is now used by most applications in OTP.

(Thanks to Tobias Schlager)

Own Id: OTP-11744

Adapt 'asm' deprecation message to new version scheme. (Thanks to Tuncer Ayaz)

Own Id: OTP-11751

A number of compiler errors where unusual or nonsensical code would crash the compiler have been reported by Ulf Norell and corrected by Anthony Ramine.

Own Id: OTP-11770

Improvements and New Features

Compilation times for modules with a huge number for record accesses using the dot operator has been improved.

Own Id: OTP-10652

The compiler can generate somewhat better code by moving let expressions into sequences. (Thanks to Anthony Ramine.)

Own Id: OTP-11056

Forbid unsized fields in patterns of binary generators and simplified v3_core's translation of bit string generators. (Thanks to Anthony Ramine.)

Own Id: OTP-11186

Funs can now be a given a name. Thanks to to Richard O'Keefe for the idea (EEP37) and to Anthony Ramine for the implementation.

Own Id: OTP-11537

Using the from_asm option to produce a BEAM file starting from BEAM assembly code would often fail because early optimization passes would not understand instructions that later optimization passes would introduce. (Thanks to Anthony Ramine.)

Own Id: OTP-11544

The .core and .S extensions are now documented in the erlc documentation, and the 'from_core' and 'from_asm' options are now documented in the compiler documentation. (Thanks to Tuncer Ayaz.)

Own Id: OTP-11547

Optimization of case expressions that build tuples or lists have been improved.

Own Id: OTP-11584

EEP43: New data type - Maps

With Maps you may for instance: M0 = #{ a => 1, b => 2}, % create associations M1 = M0#{ a := 10 }, % update values M2 = M1#{ "hi" => "hello"}, % add new associations #{ "hi" := V1, a := V2, b := V3} = M2. % match keys with values

For information on how to use Maps please see Map Expressions in the Reference Manual.

The current implementation is without the following features: No variable keys No single value access No map comprehensions

Note that Maps is experimental during OTP 17.0.

Own Id: OTP-11616

Some function specs are corrected or moved and some edoc comments are corrected in order to allow use of edoc. (Thanks to Pierre Fenoll)

Own Id: OTP-11702

Thanks to Anthony Ramine for several improvements to the optimizations in the BEAM compiler and for cleaning up the code the code that transforms list and binary comprehensions to Core Erlang.

Own Id: OTP-11720

The default encoding for Erlang source files is now UTF-8. As a temporary measure to ease the transition from the old default of latin-1, if the compiler encounters byte sequences that are not valid UTF-8 sequences, the compiler will re-try the compilation in latin-1 mode. This workaround will be removed in a future release.

Own Id: OTP-11791

Compiler 4.9.4
Fixed Bugs and Malfunctions

Typo fix ambigous -> ambiguous. Thanks to Leo Correa.

Own Id: OTP-11455

Improvements and New Features

Lift 'after' blocks to zeroary functions. Thanks to Anthony Ramine.

Own Id: OTP-11267

Compiler 4.9.3
Fixed Bugs and Malfunctions

Expressions such as 'B = is_integer(V), if B and B -> ok end' would crash the compiler.

Own Id: OTP-11240

compile:file2/2 with the option report_errors could return ErrorInfo tuples with only two elements, while the documentation says that the ErrorInfo tuple always has three elements. Also updated the documentation to add that the first element may be 'none' if no line number is applicable.

Own Id: OTP-11304 Aux Id: seq12412

Improvements and New Features

Fix matching of floating point middle-endian machines. Thanks to Johannes Weissl.

Own Id: OTP-11201

Restrict inlining of local fun references. Thanks to Anthony Ramine.

Own Id: OTP-11211

Silence a misleading warning with some comprehensions. Thanks to Anthony Ramine.

Own Id: OTP-11212

Forbid returning a match context in beam_validator. Thanks to Anthony Ramine.

Own Id: OTP-11247

Compiler 4.9.2
Fixed Bugs and Malfunctions

Compiling functions with complex boolean operations in guards could be very slow. (Thanks to Magnus Muller for reporting this issue.)

Own Id: OTP-10939

Certain guard expressions used in a receive statement could cause the compiler to crash.

Own Id: OTP-11119 Aux Id: seq12342

Improvements and New Features

Fix optimization of some binary comprehensions. Thanks to Anthony Ramine.

Own Id: OTP-11005

Use a set to store ref registers in beam_receive. Thanks to Anthony Ramine.

Own Id: OTP-11069

Fix renaming of bs_put_string instructions. Thanks to Anthony Ramine.

Own Id: OTP-11129

Compiler 4.9.1
Fixed Bugs and Malfunctions

The compiler would crash attempting to compile expressions such as "element(2, not_tuple)".

Own Id: OTP-10794

Forbid multiple values in Core Erlang sequence arguments. Thanks to José Valim and Anthony Ramine.

Own Id: OTP-10818

An unsafe optimization would cause the compiler to crash with an internal error for certain complex code sequences.

Own Id: OTP-10825 Aux Id: seq12247

Improvements and New Features

Integers in expression that will give a floating point result (such as "X / 2" will now be converted to floating point at compile-time. (Suggested by Richard O'Keefe.)

Identical floating points constans in a module will now be coalesced to one entry in the constant pool.

Own Id: OTP-10788

Compiler 4.9
Improvements and New Features

The compiler optimizations have been polished, so that the code quality will be slightly better in some cases.

Own Id: OTP-10193

Support for Unicode has been implemented.

Own Id: OTP-10302

Where necessary a comment stating encoding has been added to Erlang files. The comment is meant to be removed in Erlang/OTP R17B when UTF-8 becomes the default encoding.

Own Id: OTP-10630

Fix some wrong warnings triggered by the option inline_list_funcs. Thanks to Anthony Ramine.

Own Id: OTP-10690

Forbid local fun variables in Core Erlang guards. Thanks to Anthony Ramine.

Own Id: OTP-10706

Binary syntax matches could cause an internal consistency error in in the compiler. (Thanks to Viktor Sovietov for reporting this bug.)

Own Id: OTP-10724

Compiler 4.8.2
Fixed Bugs and Malfunctions

Modules with very many functions would compile very slowly.

Own Id: OTP-10123

compile:forms/2 will now use a {source,SourceFilePath} to set the source returned by module_info(compile) (Thanks to José Valim)

Own Id: OTP-10150

A process which had enabled trap_exit would receive EXIT messages after calling the compiler. (Thanks to Jeremy Heater.)

Own Id: OTP-10171

Fix messages ordering with column numbers

Own Id: OTP-10183

sys_pre_expand: Fix BASE never being set

Commit a612e99fb5aaa934fe5a8591db0f083d7fa0b20a turned module attributes from 2-tuples to 3-tuples but forgot to update get_base/1, breaking BASE for parametric modules.

Own Id: OTP-10184

The compiler will now issue a warning if literal tuple funs are used. For example, {erlang,is_tuple}(X) will now generate a warning.

Own Id: OTP-10185

The compiler will now warn for illegal sizes for segments in binary construction. For example, <<X:(2.5)>> will now cause the compiler to issue a warning.

Own Id: OTP-10197

Fix the erlc -MP flag

Because of a copy-and-paste error in erlc.c, the -MP flag had the same effect as -MG. As a workaround, you had to pass +makedep_phony to enable the MP option. This patch makes -MP work as intended.

Own Id: OTP-10211

Compiler 4.8.1
Fixed Bugs and Malfunctions

In rare circumstance, the compiler could crash when compiling a case statement. (Thanks to Hakan Mattsson.)

Own Id: OTP-9842

Calling a guard test (such as is_list/1) from the top-level in a guard, would cause a compiler crash if there was a local definition with the same name. Corrected to reject the program with an error message.

Own Id: OTP-9866

Using get/1 in a try block could in some cases cause an internal compiler error. (Thanks to Eric Merritt.)

Own Id: OTP-9867

An unexported on_load function would not get run if the module was compiled with the inline option. (Thanks to Yiannis Tsiouris.)

Own Id: OTP-9910

Fixed a discrepancy in compile_info

The BEAM disassembler used the atom 'none' to signify the absence of a compile_info chunk in a .beam file. This clashed with the type declaration of the compile_info field of a #beam_file{} record as containing a list. Now [] signifies the absence of this chunk. This simplifies the code and avoids a dialyzer warning.

Own Id: OTP-9917

Fix typo in `compile' doc: unmatched parenthesis (Thanks to Ricardo Catalinas Jiménez)

Own Id: OTP-9919

In a try...catch statement that always returned false, the compiler would remove calls to BIFs that could not cause an exception (such as put/2). Example of such code: try put(K, V), false catch _:_ -> false end.

Own Id: OTP-9982

Compiler 4.8
Fixed Bugs and Malfunctions

Add '-callback' attributes in stdlib's behaviours

Replace the behaviour_info(callbacks) export in stdlib's behaviours with -callback' attributes for all the callbacks. Update the documentation with information on the callback attribute Automatically generate 'behaviour_info' function from '-callback' attributes

'behaviour_info(callbacks)' is a special function that is defined in a module which describes a behaviour and returns a list of its callbacks.

This function is now automatically generated using the '-callback' specs. An error is returned by lint if user defines both '-callback' attributes and the behaviour_info/1 function. If no type info is needed for a callback use a generic spec for it. Add '-callback' attribute to language syntax

Behaviours may define specs for their callbacks using the familiar spec syntax, replacing the '-spec' keyword with '-callback'. Simple lint checks are performed to ensure that no callbacks are defined twice and all types referred are declared.

These attributes can be then used by tools to provide documentation to the behaviour or find discrepancies in the callback definitions in the callback module.

Add callback specs into 'application' module in kernel Add callback specs to tftp module following internet documentation Add callback specs to inets_service module following possibly deprecated comments

Own Id: OTP-9621

The calculation of the 'uniq' value for a fun (see erlang:fun_info/1) was too weak and has been strengthened. It used to be based on the only the code for the fun body, but it is now based on the MD5 of the BEAM code for the module.

Own Id: OTP-9667

Improvements and New Features

Variables are now now allowed in 'fun M:F/A' as suggested by Richard O'Keefe in EEP-23.

The representation of 'fun M:F/A' in the abstract format has been changed in an incompatible way. Tools that directly read or manipulate the abstract format (such as parse transforms) may need to be updated. The compiler can handle both the new and the old format (i.e. extracting the abstract format from a pre-R15 BEAM file and compiling it using compile:forms/1,2 will work). The syntax_tools application can also handle both formats.

*** POTENTIAL INCOMPATIBILITY ***

Own Id: OTP-9643

filename:find_src/1,2 will now work on stripped BEAM files (reported by Per Hedeland). The HiPE compiler will also work on stripped BEAM files. The BEAM compiler will no longer include compilation options given in the source code itself in M:module_info(compile) (because those options will be applied anyway if the module is re-compiled).

Own Id: OTP-9752

Inlining binary matching could cause an internal compiler error. (Thanks to Rene Kijewski for reporting this bug.)

Own Id: OTP-9770

Compiler 4.7.5
Fixed Bugs and Malfunctions

Compiler options given in the source code using a -compile() attribute used to be included twice in Mod:module_info(compile). They are now only included once at the beginning of the list of options.

Own Id: OTP-9534

beam_disasm: Handle stripped BEAM files

beam_disasm:file/1 would crash if asked to disassemble a stripped BEAM file without an "Attr" chunk. (Thanks to Haitao Li)

Own Id: OTP-9571

Compiler 4.7.4
Fixed Bugs and Malfunctions

If a variable is matched out in binary matching and used as the size for a binary element, it would seem to be unbound if used in a subsequent match operation. (Thanks to Bernard Duggan.)

Own Id: OTP-9134

Eliminate incorrect warning in sys_core_fold

Own Id: OTP-9152

Compiler 4.7.3
Fixed Bugs and Malfunctions

The -export_type() directive is no longer included among the attributes.

Own Id: OTP-8998

Improvements and New Features

The maximum number of allowed arguments for an Erlang function has been lowered from 256 to 255, so that the number of arguments can now fit in a byte.

Own Id: OTP-9049

Dependency generation for Makefiles has been added to the compiler and erlc. See the manual pages for compile and erlc. (Thanks to Jean-Sebastien Pedron.)

Own Id: OTP-9065

Compiler 4.7.2
Fixed Bugs and Malfunctions

Two compiler bugs (that would cause the compiler to terminate) reported by Christopher Williams have been fixed.

Own Id: OTP-8949

Improvements and New Features

The compiler would translate binary comprehensions containing tail segments in a way that would would confuse Dialyzer. For instance:

[42 || <<_:8/integer, _/bits>> <= Bits]

would produce a Dialyzer warning.

Own Id: OTP-8864

Code such as foo(A) -> <<A:0>> would crash the compiler.

Own Id: OTP-8865

The compiler could fail with an internal error when variables were exported from a receive block but the return value of the receive block were not used. (Thanks to Jim Engquist for reporting this error.)

Own Id: OTP-8888

Compiler 4.7.1
Improvements and New Features

Eliminated warnings for auto-imported BIF clashes.

Own Id: OTP-8840

Compiler 4.7
Fixed Bugs and Malfunctions

Several problems in the inliner have been fixed.

Own Id: OTP-8552

Improvements and New Features

The module binary from EEP31 (and EEP9) is implemented.

Own Id: OTP-8217

Local and imported functions now override the auto-imported BIFs when the names clash. The pre R14 behaviour was that auto-imported BIFs would override local functions. To avoid that old programs change behaviour, the following will generate an error:

Doing a call without explicit module name to a local function having a name clashing with the name of an auto-imported BIF that was present (and auto-imported) before OTP R14A

Explicitly importing a function having a name clashing with the name of an autoimported BIF that was present (and autoimported) before OTP R14A

Using any form of the old compiler directive nowarn_bif_clash

If the BIF was added or auto-imported in OTP R14A or later, overriding it with an import or a local function will only result in a warning,

To resolve clashes, you can either use the explicit module name erlang to call the BIF, or you can remove the auto-import of that specific BIF by using the new compiler directive -compile({no_auto_import,[F/A]})., which makes all calls to the local or imported function without explicit module name pass without warnings or errors.

The change makes it possible to add auto-imported BIFs without breaking or silently changing old code in the future. However some current code ingeniously utilizing the old behaviour or the nowarn_bif_clash compiler directive, might need changing to be accepted by the compiler.

*** POTENTIAL INCOMPATIBILITY ***

Own Id: OTP-8579

The undocumented, unsupport, and deprecated function lists:flat_length/1 has been removed.

Own Id: OTP-8584

Nested records can now be accessed without parenthesis. See the Reference Manual for examples. (Thanks to YAMASHINA Hio and Tuncer Ayaz.)

Own Id: OTP-8597

It is now possible to suppress the warning in code such as "list_to_integer(S), ok" by assigning the ignored value "_" like this: "_ = list_to_integer(S), ok".

Own Id: OTP-8602

receive statements that can only read out a newly created reference are now specially optimized so that it will execute in constant time regardless of the number of messages in the receive queue for the process. That optimization will benefit calls to gen_server:call(). (See gen:do_call/4 for an example of a receive statement that will be optimized.)

Own Id: OTP-8623

The compiler optimizes record operations better.

Own Id: OTP-8668

Compiler 4.6.5
Fixed Bugs and Malfunctions

Using complex boolean expressions in ifs could cause the compiler to either crash or teminate with an internal error. (Thanks to Simon Cornish.)

Own Id: OTP-8338

Bit string comprehensions can now be used in parameterized modules. (Thanks to Jebu Ittiachen.)

Own Id: OTP-8447

Improvements and New Features

The expected return value for an on_load function has been changed. (See the section about code loading in the Reference manual.)

*** POTENTIAL INCOMPATIBILITY ***

Own Id: OTP-8339

In rare circumstances when using garbaging collecting guard BIFs, the validation pass (beam_validator) would signal that the code was unsafe, when it in fact was correct. (Thanks to Kiran Khaladkar.)

Own Id: OTP-8378

The -Werror option for erlc and the compiler option warnings_as_errors will cause warnings to be treated as errors. (Thanks to Christopher Faulet.)

Own Id: OTP-8382

Macros overloading has been implemented. (Thanks to Christopher Faulet.)

Own Id: OTP-8388

Compiler 4.6.4
Fixed Bugs and Malfunctions

The compiler's 'E' option now works with modules with types and specifications.

Own Id: OTP-8238 Aux Id: OTP-8150

Certain uses of binary matching in a begin-end in a list comprehension could cause the compiler to crash or generate incorrect code.

Own Id: OTP-8271

Improvements and New Features

The documentation is now built with open source tools (xsltproc and fop) that exists on most platforms. One visible change is that the frames are removed.

Own Id: OTP-8201

The compiler could crash if invalid calls to is_record/2 was used in (for example) a list comprehension. (Thanks to Tobias Lindahl.)

Own Id: OTP-8269

The -on_load() directive can be used to run a function when a module is loaded. It is documented in the section about code loading in the Reference Manual.

Own Id: OTP-8295

Compiler 4.6.3
Improvements and New Features

Corrected liveness optimization to eliminate a compiler crash that could occur when compiling bit syntax construction code. (Thanks to Mikage Sawatari.)

Calling BIFs such as length/1 in guard context in a try/catch block could cause a compiler crash. (Thanks to Paul Fisher.)

Using filter expressions containing andalso or orelse in a list comprehension could cause a compiler crash. (Thanks to Martin Engström.)

Own Id: OTP-8054

A guard with nested 'not' operators could cause the compiler to crash. (Thanks to Tuncer Ayaz.)

Own Id: OTP-8131

Compiler 4.6.2
Fixed Bugs and Malfunctions

The compiler would crash while compiling certain complex function bodies containing receive after due to a bug in the jump optimizer (a label that had only had backward references could still be removed). (Thanks to Vincent de Phily.)

Own Id: OTP-7980

Compiler 4.6.1
Fixed Bugs and Malfunctions

Miscellaneous minor bugs fixed.

Own Id: OTP-7937

Improvements and New Features

There will be more efficient code if there is a clause that matches the empty binary and no other clauses that matches non-empty binaries.

Own Id: OTP-7924

There is new option to allow a module to have a module name other than the filename. Do not use it unless you know what you are doing.

Own Id: OTP-7927

Compiler 4.6.0.1
Fixed Bugs and Malfunctions

Using andalso/orelse or record access in a try...catch could cause a compiler crash.

Som large and complex functions could require extremely long compilation times (hours or days).

Own Id: OTP-7905

Compiler 4.6
Fixed Bugs and Malfunctions

For some complex guards which used andalso/orelse, the compiler would crash. (Thanks to Hunter Morris.)

Own Id: OTP-7679

Code that (incorrectly) used the the value of nested applications of setelement/3 in bit syntax construction could crash the compiler.

Own Id: OTP-7690

Modules containing huge integers (consisting of several hundreds of thousands of digits or more) could be slow to compile. This problem has been corrected.

Own Id: OTP-7707 Aux Id: seq11129

If the generator in a list comprehension is given a non-list term, there will now be function_clause exception instead of a case_clause exception (as it was in all releases before R12B).

Own Id: OTP-7844

Improvements and New Features

The compiler could crash if the size for a binary segment in matching was a complex literal such as binary or tuple.

Own Id: OTP-7650

The compiler generates more compact and faster code for matching of complex constants (such as constant lists and tuples).

Own Id: OTP-7655

The undocumented, unsupported, and deprecated guard BIF is_constant/1 has been removed.

*** INCOMPATIBILITY with R12B ***

Own Id: OTP-7673

The compiler generates better code for many guard expressions, and especially for guards that use andalso/orelse or record fields.

(In technical terms, andalso/orelse in a guard would case the creation of a stack frame and saving of all x registers that could potentially be alive after the guard and restoring all x registers before leaving the guard. For certain guards, far too many x registers were saved and subsequently restored. In this version of the compiler, no stack frame is created and no x registers are saved and restored.)

Own Id: OTP-7718

The default size for the resulting binary created by a binary comprehension was 64Kb in R12B (it would grow if needed). This was often far too much. In this release, the default is changed to 256 bytes. Furthermore, for most binary comprehensions without filters, the exact size of the resulting binary can be calculated beforehand and the compiler now generates code that does that calculation.

Own Id: OTP-7737

The short-circuit operators andalso and orelse no longer guarantees that their second argument is either true or false. As a consequence, andalso/orelse are now tail-recursive.

*** POTENTIAL INCOMPATIBILITY ***

Own Id: OTP-7748

The compiler will refuse to a compile file where the module name in the file differs from the output file name.

When compiling using erlc, the current working directory will no be included in the code path (unless explicitly added using "-pa .").

*** POTENTIAL INCOMPATIBILITY ***

Own Id: OTP-7793

There will no longer be any warnings for list comprehensions without generators, as such list comprehension have turned out to be useful.

Own Id: OTP-7846

Warnings for obsolete guard tests are now turned on. (That is, writing list(L) in a guard instead of is_list(L) will generate a warning.)

The warnings can be turned off using the nowarn_obsolete_guard option.

Own Id: OTP-7850

The copyright notices have been updated.

Own Id: OTP-7851

If a module contains an exported function with the same name as an auto-imported BIF (such as length/1), any calls to the BIF must have an explicit erlang: prefix, or there will be a compilation error (such calls would only generate a warning in previous releases).

(The reason for the change is to avoid breaking code in a future major release, R14 or R15, in which we plan to make calls without a module prefix always call the local function in the same module even if there is an auto-imported BIF with the same name.)

*** POTENTIAL INCOMPATIBILITY ***

Own Id: OTP-7873

Compiler 4.5.5
Fixed Bugs and Malfunctions

Matching on a zero-width segment in the bit syntax would crash the compiler. (Thanks to Will.)

Own Id: OTP-7591

Improvements and New Features

In bit syntax expressions which started with a binary segment, and was followed by at least two segments of variable size, too little space could be allocated for the binary, leading to memory corruption.

Own Id: OTP-7556

In user-defined attributes, Name/Arity is now allowed and will be translated to {Name,Arity}. (An implementation of EEP-24 by Richard O'Keefe.)

The module_info/{0,1} functions automatically inserted into each compiled modules are now documented in the Modules section in the Reference Manual.

Own Id: OTP-7586

Compiler 4.5.4
Improvements and New Features

Certain complex bit syntax matching operations matching out binaries and having several clauses could give incorrect results (the matched out binaries were too short). (Thanks to Christian von Roques for bug report and correction.)

Own Id: OTP-7498

Compiler 4.5.3
Improvements and New Features

New option warn_export_all to warn for a module using export_all. (Thanks to Richard Carlsson.)

Own Id: OTP-7392

Compiler 4.5.2.1
Fixed Bugs and Malfunctions

In rare circumstances, the length/1 BIF (and a few other guard BIFs) would seem to return an incorrect value (of any type).

Own Id: OTP-7345 Aux Id: seq10962

Compiler 4.5.2
Fixed Bugs and Malfunctions

A bug in the old inliner has been fixed. Some undocumented functionality has been removed.

Own Id: OTP-7223

Matching several binary patterns in parallel using the '=' operator is not allowed (an implementation limitation), but the compiler did not reject all such attempts (depending on the patterns, the generated code might or might not work correctly). Now the compiler rejects all binary patterns joined by '='.

Own Id: OTP-7227

Complex combinations of record operations and binary matching could cause the compiler to crash. (Thanks to Vladimir Klebansky.)

Own Id: OTP-7233

In rare circumstances, mixing binary matching clauses with clauses matching other data types, the compiler could crash.

Own Id: OTP-7240 Aux Id: seq10916

Compiler 4.5.1.1
Fixed Bugs and Malfunctions

Corrected a compiler bug that could cause a complex binary matching operation to fail when it shouldn't. (Thanks to Tomas Stejskal.)

Own Id: OTP-7188

In unusual circumstances, the environment for a fun could bind wrong values.

Own Id: OTP-7202 Aux Id: seq10887

Long sequences of list comprehensions without generators joined by the '++' operator would cause a code expansion explosion, which could cause the compiler to run out of memory. To resolve this problem, in '[...||...]++Expr', Expr is now evaluated before the list comprehension. This change is backwards compatible (see the following note about evaluation order if you have doubts).

Note about evaluation order: The Reference manual says that subexpressions are evaluated in any order before the expression itself. Therefore, in an expression such as 'LeftExpr++RightExpr', you should not depend on LeftExpr being evaluated before RightExpr or vice versa. The evaluation order is only important if the expressions contains and/or depends on operations with side-effects, such as message passing or ets operations.

Own Id: OTP-7206

Compiler 4.5.1
Fixed Bugs and Malfunctions

A match expression inside a function call could cause a false "a term is constructed but never used" warning.

Own Id: OTP-7018 Aux Id: seq10824

The compiler could crash if a binary tail was matched out, and then used in a binary append operation. (Thanks to Oleg Avdeev.)

Similarly, the compiler could crash if a binary tail was matched out, and then used (incorrectly) in binary construction in an integer field. (Thanks to Fredrik Svahn.) Or was incorrectly used in a float field. Or was used in a binary field with a given length. (Thanks to Chih - Wei Yu.)

Own Id: OTP-7022

Matching an empty binary in a record and then using the same record again could cause a compiler crash. (Thanks to Fredrik Thulin.)

Own Id: OTP-7029

In rare circumstances, constants containing floating points and integers could be confused. Example:

f(a) -> [1]; f(b) -> [1.0].

Both f(a) and f(b) would return [1].

Own Id: OTP-7073

Some bit syntax code such as

matching d(_,<$lt;$gt;$gt;) -> one; d(0,<$lt;D$gt;$gt;) ->two.

could crash the compiler. (Thanks to Simon Cornish.)

Own Id: OTP-7094

In unusual circumstances, a call to a fun could fail due to an unsafe optimization. (Thanks to Simon Cornish.)

Own Id: OTP-7102

Bit syntax matching with a guard containing two or more uses of andalso/orelse could cause the compiler to crash. (Thanks to Mateusz Berezecki.)

Own Id: OTP-7113

This was only a problem if you generated or wrote your own Core Erlang code: The Core Erlang optimizer code could move nested calls such as erlang:'$lt;'(erlang:length(L), 2) as case expression into a guard, which would change the semantics. (Thanks to Robert Virding.)

Own Id: OTP-7117

Improvements and New Features

The compiler could generate suboptimal code for record updates if the record update code consisted of multiple source code lines.

Own Id: OTP-7101

Compiler 4.5
Fixed Bugs and Malfunctions

The compiler used to allow that a binary field without size could be used in other positions than at the end in bit syntax pattern. For instance, > = Bin]]> used to compile, but now the compilation will fail with an an error message.

Also, it is now longer permitted to give a literal string in a binary pattern a type or a size; for instance, > = Bin]]> will no longer compile. (In previous releases, there would always be a badmatch exception at run-time.)

Own Id: OTP-6885

Improvements and New Features

Bitstrings (bit-level) binaries and binary comprehensions are now part of the language. See the Reference Manual.

Own Id: OTP-6558

The 'compressed' option for the compiler has been documented.

Own Id: OTP-6801

If the value of a list comprehension is not used, such as in '[do_something(X) || X <- List], ok', a result list will no longer be built. For more details, see the Efficiency Guide.

If the value of an expression is not used, and the expression has no side effects except for possibly throwing an exception, a warning will be generated. Examples: 'self(),ok' and '{error,Reason},ok'.

Own Id: OTP-6824

Three new functions have been added to the compile module: noenv_file/2, noenv_forms/2, and noenv_output_generated/1.

Own Id: OTP-6829

Many bit syntax operations, both construction and matching, are faster. For further information, see the Efficiency Guide.

Own Id: OTP-6838

Literal lists, tuples, and binaries are no longer constructed at run-time as they used to be, but are stored in a per-module constant pool. Literals that are used more than once are stored only once.

This is not a change to the language, only in the details of its implementation. Therefore, the implications of this change is described in the Efficiency Guide.

Example 1: In the expression element(BitNum-1, {1,2,4,8,16,32,64,128}), the tuple used to be constructed every time the expression was executed, which could be detrimental to performance in two ways if the expression was executed in a loop: the time to build the tuple itself and the time spent in garbage collections because the heap filled up with garbage faster.

Example 2: Literal strings, such as "abc", used to be stored in the compiled code compactly as a byte string and expanded to a list at run-time. Now all strings will be stored expanded to lists (such as [$a,$b,$c]) in the constant pool. That means that the string will be faster to use at run-time, but that it will require more space even when not used. If space is an issue, you might want to use binary literals (that is, <<"abc"<<) instead of string literals for infrequently used long strings (such as error messages).

Own Id: OTP-6850

Recursive calls now usually consume less stack than in R11B. See the Efficiency Guide.

Own Id: OTP-6862 Aux Id: seq10746

Two new guard BIFs have been introduced as a recommended replacement for size/1. (The size/1 BIF will be removed no earlier than in R14B.) The BIFs are tuple_size/1 to calculate the size of a tuple and byte_size/1 to calculate the number of bytes needed for the contents of the binary or bitstring (rounded up to the nearest number of bytes if necessary).

There is also a new bit_size/1 BIF that returns the exact number of bits that a binary or bitstring contains.

Own Id: OTP-6902

The two internal functions erl_bifs:is_bif/3 and erl_bifs:is_guard/3 have been removed. They were unsupported, undocumented, and unmaintained.

Own Id: OTP-6966

Compiler 4.4.5
Fixed Bugs and Malfunctions

The compiler would crash if you tried to combine to non-list literals with '' (for instance, ).

Own Id: OTP-6630 Aux Id: seq10635

Improvements and New Features

Minor Makefile changes.

Own Id: OTP-6689

Compiler 4.4.4
Fixed Bugs and Malfunctions

Incorrect code could be generated for bit syntax matching if the old inliner was used with aggressive settings.

Own Id: OTP-6461

Compiler 4.4.3
Fixed Bugs and Malfunctions

The R10B compiler could generate unsafe instructions that could cause memory corruption. (The R11B compiler does not have that problem.) The erlang emulator will now refuse to load R10B-compiled modules that contain such unsafe instructions. In addition, the beam_validator module in the compiler will also reject such instructions (in case it is used to validate R10B code). (Thanks to Matthew Reilly.)

Own Id: OTP-6386

Improvements and New Features

Directives for parse transforms that have been run are now removed from the abstract code stored when the debug_info option is given, to prevent the parse transforms to be run again.

Own Id: OTP-5344

Minor improvements in code generation for some guards expression involving boolean expressions.

Own Id: OTP-6347

Compiler 4.4.2.1
Fixed Bugs and Malfunctions

The compiler could generate incorrect code for bit syntax matching consisting of several clauses.

Own Id: OTP-6392 Aux Id: seq10539

Compiler 4.4.2
Fixed Bugs and Malfunctions

Defining a fun itself containing a fun in an block of a would cause the compiler to crash or generate incorrect code. (Thanks to Tim Rath.)

Shorter compilation times for modules containing with an extreme number of functions (10000 functions or more).

(The compiled could generate deprecated instructions for certain bit syntax matching operations.)

Own Id: OTP-6212 Aux Id: seq10446

Fixed several bugs that would cause warnings to be shown without file name and line number.

Own Id: OTP-6260 Aux Id: seq10461

Improvements and New Features

The option is now default; that is, reading a field from a record using the syntax will fail if is not a record of the correct type.

If necessary, the record tests can be turned off by giving the option. To avoid editing Makefiles, the environment variable can be set to "".

The option will probably be removed in the R12B release.

*** POTENTIAL INCOMPATIBILITY ***

Own Id: OTP-6294

Compiler 4.4.1
Fixed Bugs and Malfunctions

The compiler used to crash if a module contained code similar to ' ok end]]>'. (Thanks to Richard Carlsson.)

The compiler would spend really long time compiling bit syntax expressions such as '>]]>' and produce a huge .beam file. Corrected.

The compiler would compile list comprehensions with many generators really, really slow. (Thanks to Thomas Raes.)

Module attributes would be stored in reverse order compared to the order in the source code. (Thus, would also return the attributes in reversed order.)

Defining a fun in an block of a would cause the compiler to crash or generate incorrect code. (Thanks to Martin Bjorklund.)

The combination of binary pattern and a guard with andalso/orelse could cause the compiler to crash.

Own Id: OTP-6121 Aux Id: seq10400

Compiler 4.4
Fixed Bugs and Malfunctions

When a file is included using , the include path is temporarily updated to include the directory the file was found in, which will allow that file to itself include files from the same directory using . (Thanks to Richard Carlsson.)

Own Id: OTP-5944

Improvements and New Features

The and operators are now allowed to be used in guards. That also applies to match specifications.

Own Id: OTP-5894 Aux Id: OTP-5149

When given the new option , the compiler will generate code that verifies the record type for operations in guards. Code that verifies record types in bodies has already been generated since R10B, but in this release there will be a instead of a if the record verification test fails. See for more information.

The Erlang shell always applies strict record tests.

Own Id: OTP-5915 Aux Id: OTP-5714

The BIF can now be used in guards. Also, can now be called without an module prefix for consistency with the other functions.

Own Id: OTP-5916

The compiler options and , which allowed code that used unquoted or as atoms or record tags, has been removed. Old code that depended on the options need to be revised to have occurrences of or as atom or record tags single-quoted. (Note: Although is a reserved keyword, there is no statement. It might be introduced in a future release.)

*** POTENTIAL INCOMPATIBILITY ***

Own Id: OTP-6058

Compiler 4.3.12
Improvements and New Features

The following code would crash the compiler: T #r{s = "x"} end]]>. (Thanks to Richard Carlsson.)

The compiler could crash if binaries were constructed in certain guards involving boolean operators (including semicolon). (Thanks to Torbjorn Tornkvist.)

Own Id: OTP-5872

The compiler will now warn that the function is deprecated.

Own Id: OTP-5976

Compiler 4.3.11
Improvements and New Features

The compiler would assume that some patterns with aliases ('=') would not match if they were split into several lines. (Thanks to Peter Nagy/Mats Cronqvist.)

Minor cleanups to eliminate Dialyzer warnings.

Own Id: OTP-5791 Aux Id: seq10141

Compiler 4.3.10
Fixed Bugs and Malfunctions

When given the new option , the compiler will generate code that verifies the record type for operations (in body context only, not in guards). See the documentation for the module for more information.

The beam validator pass of the compiler could crash given in rare circumstances when given certain combinations of catches and record operations. (Thanks to Mats Cronqvist.)

Attributes containing binaries (such as -a(<<1,2,3>>)) would crash the compiler. (Thanks to Roger Price.)

Multiple behaviours in the same module will no longer generate a warning, unless one or more callbacks for the behaviours overlap. For instance, using both the and behaviours in the same module will NOT generate any warning, but using and will.

Own Id: OTP-5714 Aux Id: seq10073

The pre-processor used to complain that the macro definition was circular, which it isn't. (Thanks to Richard Carlsson.)

Own Id: OTP-5777

Compiler 4.3.9
Fixed Bugs and Malfunctions

Updating at least two fields of a record with a literal string could cause the compiler to generate dangerous code that could cause a crash at run-time (e.g. ). (Thanks to Mikael Karlsson.)

Unecessary tests (such as a 'case' with two case branches that were identical) could cause the compiler to crash. (Thanks to Fredrik Thulin.)

The validation pass of the compiler could generate an error for correct code when floating point operations were used in try/catch statements.

In bit syntax construction, any field following a binary field would always be marked as "aligned" (which may or may not be correct). That would cause the hipe native compiler to generate incorrect code if the field was in fact unaligned. (Thanks to Per Gustafsson.)

Some complex guard expressions (such as ) would crash the compiler. (Thanks to Sean Hinde.)

Compilation speed has been increased for modules with many functions and/or atoms (such as modules generated by the Asn1 application or other code generators).

Own Id: OTP-5632 Aux Id: seq10057

Compiler 4.3.8
Fixed Bugs and Malfunctions

In some circumstances, having two try/catch constructs following each in a function body, would cause an internal error to be generated (when in fact the generated code was correct). (Thanks to Fredrik Thulin.)

Incorrect calls such as would crash the compiler. The compiler now generates a warning. (Thanks to Ulf Wiger.)

Own Id: OTP-5553

Improvements and New Features

The new construct creates a fun that refers to the latest version of . This syntax is meant to replace tuple funs which have many problems.

The new type test (which may be used in guards) test whether is a fun that can be applied with arguments. (Currently, can also be a tuple fun.)

Own Id: OTP-5584

Compiler 4.3.7
Improvements and New Features

Further improvements of encrypted debug info: New option for compiler.

Own Id: OTP-5541 Aux Id: seq9837

Compiler 4.3.6
Fixed Bugs and Malfunctions

Fixed a bug in the validator of the generated code (beam_validator) which caused an internal compiler error even though the generated code was indeed correct.

Own Id: OTP-5481 Aux Id: seq9798

Improvements and New Features

It is now possible to encrypt the debug information in Beam files, to help keep the source code secret. See the documentation for on how to provide the key for encrypting, and the documentation for on how to provide the key for decryption so that tools such as the Debugger, Xref, or Cover can be used.

The functions now accepts an additional chunk type to retrieve the compilation information directly as a term. (Thanks to Tobias Lindahl.)

Own Id: OTP-5460 Aux Id: seq9787

Compiler 4.3.5
Fixed Bugs and Malfunctions

Complex functions could cause the internal validator in the compiler to generate an internal error even though the generated code was correct.

Own Id: OTP-5436 Aux Id: seq9781

Compiler 4.3.4
Fixed Bugs and Malfunctions

In rare circumstances, incorrect code for record or tuple access could be generated. The incorrect code would either trigger an internal error in the compiler or cause an exception at run time. (Thanks to Martin Bjorklund.)

Corrected a bug in in bit syntax matching where clauses could match in the wrong order. (Thanks to Ulf Wiger.)

Own Id: OTP-5404 Aux Id: seq9767

Compiler 4.3.3
Improvements and New Features

Given bit syntax construction in certain complex contexts involving a catch, the compiler would either crash or terminate due to failure in an internal consistency check. (Thanks to Fredrik Thulin.)

Matches such as > = <<103133:64/float>>]]> used to fail. Now they succeed.

Shadowing of variables in bit syntax matches in fun heads such as in >) -> B end]]> was handled incorrectly by the compiler. The fun used to be compiled as if it was written 'fun(<<8:8,B:8>>)]]>, while it should be compiled in the same way as >)]]>.

A bug in the validation pass has been corrected. It sometimes occurred when the compiler optimized by reusing code for causing an exception when the reused code was called from within catch or try-catch statements. Then the validator refused to approve the code and complained about >) -> B end]]> was handled incorrectly by the in the same way as >)]]>.

A bug in the unknown_catch_try_state.

Corrected a bug in the optimizer that would cause the compiler to crash. (Thanks to Peter-Henry Mander.)

There are now warnings generated if a bit syntax construction will fail at run-time because of a type mismatch (e.g. >]]>).

Own Id: OTP-5342 Aux Id: OTP-5118, OTP-5270, OTP-5323

Binary pattern matching such as > = <)]]> used to silently fail at runtime (i.e. never match). The compiler now generates an error for any such patterns.

Own Id: OTP-5371

Compiler 4.3.2
Fixed Bugs and Malfunctions

In rare cases, the code compiler code generate code for a tuple match that could crash the emulator if passed a term that was not a tuple.

If a bit syntax construction failed within a catch, previously assigned variables could get the wrong value.

The compiler now runs a validation pass on the generated code and aborts before writing a Beam file if any suspect code is found. In particular, the validation pass checks for incorrect code that may cause emulator crashes or other strange symptoms in the emulator.

Some corrections to the unsupported feature parameterized modules by Richard Carlsson (HiPE).

Own Id: OTP-5247 Aux Id: OTP-5235

Compiler 4.3.1
Fixed Bugs and Malfunctions

Corrected the release note regarding below. DOES work in the initial R10B release.

A few minor issues code generation issues were corrected. Although the generated code was correct, it was slightly slower and larger than it needed to be.

A debug printout (that could be seen in rare circumstances) has been removed.

and similar expressions in a guard would fail.

New options and to do a quick check of the code of a module.

The option was not recognized if it appeared in a directive inside the module.

Corrected some bugs in the undocumented feature "parameterized modules".

Own Id: OTP-5198

When the undocumented feature "parameterized modules" was used, the macro did not work correctly.

Own Id: OTP-5224