Changelog for Elixir v1.20
View SourceType system improvements
Full type inference
Elixir now performs inference of whole functions. The best way to show the new capabilities are with examples. Take the following code:
def add_foo_and_bar(data) do
data.foo + data.bar
endElixir now infers that the function expects a map as first argument, and the map must have the keys .foo and .bar whose values are either integer() or float(). The return type will be either integer() or float().
Here is another example:
def sum_to_string(a, b) do
Integer.to_string(a + b)
endEven though the + operator works with both integers and floats, Elixir infers that a and b must be both integers, as the result of + is given to a function that expects an integer. The inferred type information is then used during type checking to find possible typing errors.
Acknowledgements
The type system was made possible thanks to a partnership between CNRS and Remote. The development work is currently sponsored by Fresha and Dashbit.
v1.20.0-dev
1. Enhancements
Elixir
- [Enum] Add
Enum.min_maxsorter - [Integer] Add
Integer.ceil_div/2 - [Kernel] Print intermediate results of
dbgfor pipes - [Kernel] Warn on unused requires
- [Regex] Add
Regex.import/1to import regexes defined with/E
ExUnit
- [ExUnit.CaptureLog] Add
:formatteroption for custom log formatting
Mix
- [mix test] Add
mix test --dry-run
2. Bug fixes
3. Soft deprecations (no warnings emitted)
4. Hard deprecations
Elixir
- [File]
File.stream!(path, modes, lines_or_bytes)is deprecated in favor ofFile.stream!(path, lines_or_bytes, modes) - [Kernel] Matching on the size inside a bit pattern now requires the pin operator for consistency, such as
<<x::size(^existing_var)>> - [Kernel.ParallelCompiler]
Kernel.ParallelCompiler.async/1is deprecated in favor ofKernel.ParallelCompiler.pmap/2, which is more performant and addresses known limitations
Logger
- [Logger]
Logger.*_backendfunctions are deprecated in favor of handlers. If you really want to keep on using backends, see the:logger_backendspackage - [Logger]
Logger.enable/1andLogger.disable/1have been deprecated in favor ofLogger.put_process_level/2andLogger.delete_process_level/1
v1.19
The CHANGELOG for v1.19 releases can be found in the v1.19 branch.