Age | Commit message (Collapse) | Author |
|
Reported-by: José Valim
|
|
Update erlang lint and syntax expand for #{ K := V }
|
|
|
|
|
|
This adds optional names to fun expressions. A named fun expression
is parsed as a tuple `{named_fun,Loc,Name,Clauses}` in erl_parse.
If a fun expression has a name, it must be present and be the same in
every of its clauses. The function name shadows the environment of the
expression shadowing the environment and it is shadowed by the
environment of the clauses' arguments. An unused function name triggers
a warning unless it is prefixed by _, just as every variable.
Variable _ is allowed as a function name.
It is not an error to put a named function in a record field default
value.
When transforming to Core Erlang, the named fun Fun is changed into
the following expression:
letrec 'Fun'/Arity =
fun (Args) ->
let <Fun> = 'Fun'/Arity
in Case
in 'Fun'/Arity
where Args is the list of arguments of 'Fun'/Arity and Case the
Core Erlang expression corresponding to the clauses of Fun.
This transformation allows us to entirely skip any k_var to k_local
transformation in the fun's clauses bodies.
|
|
|
|
|
|
Conflicts:
lib/diameter/autoconf/vxworks/sed.general
xcomp/README.md
|
|
|
|
Tuple funs were deprecated in R15B (in commit a4029940e309518f5500).
|
|
Commit a612e99fb5aaa934fe5a8591db0f083d7fa0b20a turned module attributes from
2-tuples to 3-tuples but forgot to update get_base/1, breaking BASE for
parametric modules.
|
|
Use a gb_set instead of an ordset to store the set of defined
functions in the module to avoid quadritic time complexity.
|
|
* bjorn/fun-improvements/OTP-9667:
sys_pre_expand: Remove incorrect comment
compiler: Eliminate use of deprecated erlang:hash/2
beam_asm: Fix broken NewIndex in fun entries
beam_asm: Strenghten the calculation of Uniq for funs
|
|
sys_pre_expand does not keep track of used or new variables (and have
not done since about the time Core Erlang was introduced).
|
|
Now that beam_asm computes the Index and Uniq values for funs, there
is no need to compute those values in the sys_pre_expand and v3_kernel
modules, thus eliminating the calls to the deprecated erlang:hash/2
function.
It would be tempting to stop generating the name for the fun in
sys_pre_expand so that we did not have to add the Info field to a tuple.
But:
* The debugger depends on the name being there. (Simple solution:
Let the debugger generate the name itself.)
* When a fun has been inlined into another function, the fun name in
'id' annotation will be used to notice the inlining and change the
final clause of the top-level case from generating a 'function_clause'
exception to a case_clause exception. (Possible workaround: Have the
inliner set an inlined attribute on functions that have been inlined, or
have the inliner rewrite 'function_clause' exceptions itself.)
|
|
Currently, the external fun syntax "fun M:F/A" only supports
literals. That is, "fun lists:reverse/1" is allowed but not
"fun M:F/A".
In many real-life situations, some or all of M, F, A are
not known until run-time, and one is forced to either use
the undocumented erlang:make_fun/3 BIF or to use a
"tuple fun" (which is deprecated).
EEP-23 suggests that the parser (erl_parse) should immediately
transform "fun M:F/A" to "erlang:make_fun(M, F, A)". We have
not followed that approach in this implementation, because we
want the abstract code to mirror the source code as closely
as possible, and we also consider erlang:make_fun/3 to
be an implementation detail that we might want to remove in
the future.
Instead, we will change the abstract format for "fun M:F/A" (in a way
that is not backwards compatible), and while we are at it, we will
move the translation from "fun M:F/A" to "erlang:make_fun(M, F, A)"
from sys_pre_expand down to the v3_core pass. We will also update
the debugger and xref to use the new format.
We did consider making the abstract format backward compatible if
no variables were used in the fun, but decided against it. Keeping
it backward compatible would mean that there would be different
abstract formats for the no-variable and variable case, and tools
would have to handle both formats, probably forever.
Reference: http://www.erlang.org/eeps/eep-0023.html
|
|
'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.
|
|
|
|
Any compiler options given with a -compile() attribute in source file
would be included both at the beginning and the end of the option list
for the compiler. Including the options twice is harmless during
compilation, but since the options will also be available in
Mod:module_info(compile), including them twice will waste memory.
Include the options from the source first in the list so that they
override options given on the command line.
|
|
|
|
Import directives still not sorted out!
|
|
* ks/compiler:
compiler: keep line numbers for attributes
compiler Makefile: alphabetize module names
compile.erl: eliminate compiler warning
|
|
In the future, we might want to generate warnings
for attributes, referring to them with line numbers.
sys_pre_expand used to replace line number for attributes
with 0. Change sys_pre_expand to retain the real line
number.
v3_core used to throw away the line numbers. Change
v3_core so that it retains the line numbers in annotations.
While at it, do some tidying as suggested by tidier.
|
|
|