Skip to content

Releases: elixir-lang/elixir

v1.7.0

25 Jul 20:44
Compare
Choose a tag to compare

Elixir v1.7 is the last release to support Erlang/OTP 19. We recommend everyone to migrate to Erlang/OTP 20+.

Documentation metadata

Elixir v1.7 implements EEP 48. EEP 48 aims to bring documentation interoperability across all languages running on the Erlang VM. The documentation format proposed by EEP 48 also supports metadata, which is now fully exposed to Elixir developers:

@moduledoc "A brand new module"
@moduledoc authors: ["Jane", "Mary"], since: "1.4.0"

Passing metadata is supported on @doc, @moduledoc and @typedoc.

To access the new documentation format, developers should use Code.fetch_docs/1. The old documentation format is no longer available and the old Code.get_docs/2 function will return nil accordingly.

Tools like IEx and ExDoc have been updated to leverage the new format and show relevant metadata to users. While Elixir allows any metadata to be given, those tools currently exhibit only :deprecated and :since. Other keys may be shown in the future.

The __STACKTRACE__ construct

Erlang/OTP 21.0 introduces a new way to retrieve the stacktrace that is lexically scoped and no longer relies on side-effects like System.stacktrace/0 does. Before one would write:

try do
  ... something that may fail ...
rescue
  e ->
    log(e, System.stacktrace())
    reraise(e, System.stacktrace())
end

In Elixir v1.7, this can be written as:

try do
  ... something that may fail ...
rescue
  e ->
    log(e, __STACKTRACE__)
    reraise(e, __STACKTRACE__)
end

This change may also yield performance improvements in the future, since the lexical scope allows us to track precisely when a stacktrace is used and we no longer need to keep references to stacktrace entries after the try construct finishes.

Other parts of the exception system have been improved. For example, more information is provided in certain occurrences of ArgumentError, ArithmeticError and KeyError messages.

Erlang/OTP logger integration

Erlang/OTP 21 includes a new :logger module. Elixir v1.7 fully integrates with the new :logger and leverages its metadata system. The Logger.Translator mechanism has also been improved to export metadata, allowing custom Logger backends to leverage information such as:

  • :crash_reason - a two-element tuple with the throw/error/exit reason as first argument and the stacktrace as second

  • :initial_call - the initial call that started the process

  • :registered_name - the process registered name as an atom

We recommend Elixir libraries that previously hooked into Erlang's :error_logger to hook into Logger instead, in order to support all current and future Erlang/OTP versions.

Other Logger improvements

Previously, Logger macros such as debug, info, and so on would always evaluate their arguments, even when nothing would be logged. From Elixir v1.7, the arguments are only evaluated when the message is logged.

The Logger configuration system also accepts a new option called :compile_time_purge_matching that allows you to remove log calls with specific compile-time metadata. For example, to remove all logger calls from application :foo with level lower than :info, as well as remove all logger calls from Bar.foo/3, you can use the following configuration:

config :logger,
  compile_time_purge_matching: [
    [application: :foo, level_lower_than: :info],
    [module: Bar, function: "foo/3"]
  ]

ExUnit improvements

ExUnit has also seen its own share of improvements. Assertions such as assert some_fun(arg1, arg2, arg3) will now include the value of each argument in the failure report:

  1) test function call arguments (TestOneOfEach)
     lib/ex_unit/examples/one_of_each.exs:157
     Expected truthy, got false
     code: assert some_vars(1 + 2, 3 + 4)
     arguments:

         # 1
         3

         # 2
         7

     stacktrace:
       lib/ex_unit/examples/one_of_each.exs:158: (test)

Furthermore, failures in doctests are now colored and diffed.

On the mix test side of things, there is a new --failed flag that runs all tests that failed the last time they ran. Finally, coverage reports generated with mix test --cover include a summary out of the box:

Generating cover results ...

Percentage | Module
-----------|--------------------------
   100.00% | Plug.Exception.Any
   100.00% | Plug.Adapters.Cowboy2.Stream
   100.00% | Collectable.Plug.Conn
   100.00% | Plug.Crypto.KeyGenerator
   100.00% | Plug.Parsers
   100.00% | Plug.Head
   100.00% | Plug.Router.Utils
   100.00% | Plug.RequestId
       ... | ...
-----------|--------------------------
    77.19% | Total

1. Enhancements

Elixir

  • [Calendar.ISO] Support negative dates in Calendar.ISO
  • [Calendar] Add Calendar.months_in_year/1 callback
  • [Code] Add Code.compile_file/2 that compiles files without leaving footprints on the system
  • [Code] Add Code.purge_compiler_modules/0 that purges any compiler module left behind. This is useful for live systems dynamically compiling code
  • [Code] Add Code.fetch_docs/1 that returns docs in the EEP 48 format
  • [Date] Add Date.months_in_year/1 function
  • [DynamicSupervisor] Use the name of the DynamicSupervisor as the ID whenever possible
  • [Exception] Provide "did you mean" suggestions on KeyError
  • [Exception] Provide more information on ArithmeticError on Erlang/OTP 21+
  • [Function] Add Function module with capture/3, info/1 and info/2 functions
  • [GenServer] Support the new handle_continue/2 callback on Erlang/OTP 21+
  • [IO.ANSI] Add cursor movement to IO.ANSI
  • [Kernel] Support adding arbitrary documentation metadata by passing a keyword list to @doc, @moduledoc and @typedoc
  • [Kernel] Introduce __STACKTRACE__ to retrieve the current stacktrace inside catch/rescue (this will be a requirement for Erlang/OTP 21+)
  • [Kernel] Raise on unsafe variables in order to allow us to better track unused variables (also known as imperative assignment / variable leakage)
  • [Kernel] Warn when using length to check if a list is not empty on guards
  • [Kernel] Add hints on mismatched do/end and others pairs
  • [Kernel] Warn when comparing structs using the >, <, >= and <= operators
  • [Kernel] Warn on unsupported nested comparisons such as x < y < z
  • [Kernel] Warn if redefining documentation across clauses of the same definition
  • [Kernel] Warn on unnecessary quotes around atoms, keywords and calls
  • [Macro] Add Macro.special_form?/2 and Macro.operator?/2 that returns true if the given name/arity is a special form or operator respectively
  • [Macro.Env] Add Macro.Env.vars/1 and Macro.Env.has_var?/2 that gives access to environment data without accessing private fields
  • [Regex] Include endianness in the regex version. This allows regexes to be recompiled when an archive is installed in a system with a different endianness
  • [Registry] Add Registry.count/1 and Registry.count_match/4
  • [String] Update to Unicode 11
  • [StringIO] Add StringIO.open/3
  • [System] Use ISO 8601 in System.build_info/0

ExUnit

  • [ExUnit.Assertion] Print the arguments in error reports when asserting on a function call. For example, if assert is_list(arg) fails, the argument will be shown in the report
  • [ExUnit.Diff] Improve diffing of lists when one list is a subset of the other
  • [ExUnit.DocTest] Show colored diffs on failed doctests
  • [ExUnit.Formatter] Excluded tests, via the --exclude and --only flags, are now shown as "Excluded" in reports. Tests skipped via @tag :skip are now exclusively shown as "Skipped" and in yellow

IEx

  • [IEx.Helpers] Add use_if_available/2
  • [IEx.Helpers] Allow force: true option in recompile/1
  • [IEx.Helpers] Add :allocators pane to runtime_info/1
  • [IEx.Helpers] Show documentation metadata in h/1 helpers

Logger

  • [Logger] Ensure nil metadata is always pruned
  • [Logger] Only evaluate Logger macro arguments when the message will be logged
  • [Logger] Add :compile_time_purge_matching to purge logger calls that match certain compile time metadata, such as module names and application names
  • [Logger] Log to :stderr if a backend fails and there are no other backends
  • [Logger] Allow translators to return custom metadata
  • [Logger] Return :crash_reason, :initial_call and :registered_name as metadata in crash reports coming from Erlang/OTP

Mix

  • [mix archive.install] Add support for the Hex organization via --organization
  • [mix archive.uninstall] Support --force flag
  • [mix compile] Improve support for external build tools such as rebar
  • [mix deps] Include override: true in rebar dependencies to make the behaviour closer to how rebar3 works (although diverged deps are still marked as diverged)
  • [mix escript.install] Add support for the Hex organization via --organization
  • [mix escript.uninstall] Support --force flag
  • [mix help] Also list aliases
  • [mix local] Use ipv6 with auto fallback to ipv4 when downloading data
  • [mix profile] Allow all profiling tasks to run programatically
  • [mix test] Add --failed option that only runs previously failed tests
  • [mix test] Print coverage summary by default when the --cover flag is given
  • [Mix.Project] Add Mix.Project.clear_deps_cache/0
  • [Mix.Project] Add Mix.Project.config_mtime/0 that caches the config mtime values to avoid filesystem access

2. Bug fixes

Elixir

  • [IO.ANSI.Docs] Fix table column alignment when converting docs to ANSI escapes
  • [Code] Ensure string_to_quoted ...
Read more

v1.7.0-rc.1

19 Jul 10:16
Compare
Choose a tag to compare
v1.7.0-rc.1 Pre-release
Pre-release
Release v1.7.0-rc.1

v1.7.0-rc.0

13 Jul 13:12
Compare
Choose a tag to compare
v1.7.0-rc.0 Pre-release
Pre-release
Release v1.7.0-rc.0

v1.6.6

19 Jun 22:28
Compare
Choose a tag to compare

This release supports Erlang/OTP 21.0 by removing all warnings and by properly supporting the new Erlang logger module.

Important! the Precompiled.zip attachment below is precompiled on the lowest supported Erlang/OTP version, which is Erlang/OTP 19.0. Therefore, if you want to run Elixir v1.6 with Erlang/OTP 21, we recommend you to compile Elixir from source.

1. Bug fixes

Elixir

  • [Base] Do not raise when finding bad digits in Base.decode32! with case: :mixed
  • [Code] Preserve the user's choice when fn is followed by a newline and it has only a single clause
  • [DynamicSupervisor] Properly account for restarting children in the :max_children configuration
  • [String] Add performant impl for string upcase/downcase :ascii mode
  • [Task.Supervisor] Fix type spec for start_child/4

Logger

  • [Logger] Do not crash truncation when truncate is set to infinity

Mix

  • [mix format] Match files starting with dot

v1.6.5

07 May 11:35
Compare
Choose a tag to compare

This release supports Erlang/OTP 21.0-rc by removing all warnings and by properly redirecting logger output. Note it is not guaranteed it will support Erlang/OTP 21.0 final.

1. Bug fixes

  • [Code] Preserve the user's choice in the formatter on parens call with next break fits
  • [Code] Preserve the user's choice in the formatter on calls without parens when we have one argument per line
  • [Code] Fix formatting when there is a tilde in the first element of a bitstring
  • [Kernel] Support specsdiff flag on __info__ spec clauses
  • [Kernel] Do not exclude hygienic vars in defguard
  • [Kernel.SpecialForms] Mark for comprehensions as generated to avoid dialyzer warnings
  • [Macro] Make sure Macro.to_string/2 emits valid quoted expressions
  • [Task] Support :infinity timeout on Task.yield_many/2
  • [Task.Supervisor] Do not crash spawning supervised tasks when the parent process is dead
  • [URI] Fix parsing of URIs with trailing ?

v1.6.4

16 Mar 11:32
Compare
Choose a tag to compare

1. Bug fixes

Elixir

  • [Code.Formatter] Do not double escape quoted keyword list identifiers
  • [Kernel] Properly support into: binary in Erlang/OTP 20.3

v1.6.3

09 Mar 08:04
Compare
Choose a tag to compare

1. Enhancements

Elixir

  • [Code.Formatter] Support comments in the middle of pipelines, when and | expressions

2. Bug fixes

Elixir

  • [Code.Formatter] Consider commas when breaking groups
  • [Code.Formatter] Ensure proper precedence between & and operators
  • [Code.Formatter] Consider .formatter.exs when formatting stdin

Logger

  • [Logger.Translator] Ensure logger doesn't crash when reporting named DynamicSupervisor

v1.6.2

28 Feb 09:58
Compare
Choose a tag to compare

1. Enhancements

Mix

  • [mix compile.erlang] Teach Mix erlang compiler alternative spelling for -behavior declaration
  • [mix format] Support the :subdirectories configuration that points to other directories with their own .formatter.exs file. This is useful in umbrella applications. mix new --umbrella has also been changed to use this new configuration by default
  • [mix format] Include the current environment for missing dependency errors

2. Bug fixes

Elixir

  • [Code.Formatter] Ensure -> does not exceed line length
  • [DynamicSupervisor] Properly tag error reports generated by dynamic supervisors so they can be properly translated by Logger
  • [DynamicSupervisor] Consider extra arguments during child restart
  • [Kernel] Ensure arguments given to a guard defined with defguard are evaluated in the correct order
  • [Module] Do not remove docs for previous function declaration when @impl true is used
  • [Supervisor] Ensure use Supervisor properly adds the @behaviour Supervisor annotation

Mix

  • [Mix.Shell] Bring back Mix.Shell.cmd/2 - this arity was defined via a default argument that was accidentally removed

v1.6.1

29 Jan 20:04
Compare
Choose a tag to compare

1. Enhancements

Elixir

  • [DynamicSupervisor] Implement child_spec/1 for DynamicSupervisor
  • [Kernel] Raise better error messages on invalid map syntax

2. Bug fixes

Elixir

  • [Code.Formatter] Only rearrange not in operator if explicitly opted-in
  • [Code.Formatter] Ensure do blocks do not exceed line length on calls with a single argument
  • [Collectable] Support bitstrings in Collectable and for-comprehensions (regression in v1.6.0)
  • [GenServer] Do not override user own @opts attribute
  • [Enum] Reintroduce zipping of any enumerable of enumerables in Enum.zip/1 (regression in v1.6.0)
  • [Macro] Reorder kw blocks in Macro.to_string/1 to avoid warnings
  • [Protocol] Fix protocol consolidation when some chunks may be missing
  • [Stream] Reintroduce zipping of any enumerable of enumerables in Stream.zip/1 (regression in v1.6.0)
  • [Supervisor] Do not override user own @opts attribute
  • [Supervisor] Add @spec to second clause of start_link/2

ExUnit

  • [ExUnit.Case] Reintroduce :case in ExUnit setup/setup_all/test context

v1.6.0

17 Jan 18:45
Compare
Choose a tag to compare

Official announcement: https://elixir-lang.org/blog/2018/01/17/elixir-v1-6-0-released/

1. Enhancements

EEx

  • [EEx] Allow markers / and | to be used in a custom EEx engine

Elixir

  • [Calendar] Add truncate to Time, DateTime and NaiveDateTime to facilitate microsecond precision pruning
  • [Code] Add format_string!/2 and format_file!/2 for automatic code formatting
  • [Code] Support column annotations in quoted expressions with columns: true in Code.string_to_quoted/2
  • [DynamicSupervisor] Add DynamicSupervisor designed to manage children that are added and removed dynamically
  • [Exception] Make Exception.blame/3 extensible by adding an optional blame/2 callback to exceptions
  • [Exception] Improve the printing of guards on blamed exceptions
  • [Enumerable] Add Enumerable.slice/1 and optimize many Enum operations with the new protocol. This allows data-structures with index-based random access to provide a non-linear implementation
  • [Inspect] Show UTF-8 BOM on inspected strings
  • [Inspect.Algebra] Add :strict and :flex breaks - this gives more control over the document fitting
  • [Inspect.Algebra] Allow a group to inherit the parent group break
  • [Inspect.Algebra] Add force_unfit/1 and next_break_fits/2 which give more control over document fitting
  • [Inspect.Algebra] Add collapse_lines/1 for collapsing multiple lines to a maximum value
  • [Inspect.Algebra] Allow nest/2 to be :reset or be set to the current :cursor position
  • [Kernel] Prefix variables with V when emitting Erlang code. This improves the integration with tools such as Erlang code formatters and the GUI debugger
  • [Kernel] Warn on the use of length(x) == 0 in guards
  • [Kernel] Warn if catch comes before rescue in try
  • [Kernel] Warn if heredoc is outdented compared to its closing quotes
  • [Kernel] Add defguard/1 and defguardp/1 to make it easier to build guard-safe macros
  • [Kernel.ParallelCompiler] Add compile/2, compile_to_path/3 and require/2 which provide detailed information about warnings and errors
  • [Kernel.SpecialForms] Support the uniq: true flag in for comprehensions
  • [Module] Introduce @deprecated and @since attributes
  • [List] Rearrange equals and inserts for shorter diff scripts in List.myers_difference/2
  • [Record] Allow :macros and :includes to be given to Record.extract/2
  • [Stream] Add Stream.intersperse/2
  • [String] Update to Unicode 10
  • [String] Allow passing empty string match to String.replace/4
  • [String] Support context and language sensitive operations in String.upcase/2 and String.downcase/2. Currently only the :greek context is supported
  • [String] Support :ascii conversion in String.upcase/2 and String.downcase/2
  • [Time] Add Time.add/3

ExUnit

  • [ExUnit.Assertions] Perform inclusive checks in assert_in_delta
  • [ExUnit.Callbacks] Add ExUnit.Callbacks.start_supervised!/2
  • [ExUnit.Case] Generate a random seed per test based on the test suite seed

IEx

  • [IEx.Autocomplete] Provide contextual autocompletion: t Enum. will autocomplete types, b Enum will autocomplete callbacks
  • [IEx.CLI] Provide hints for developers when a bad host name is given to --remsh
  • [IEx.Helpers] Automatically include specs when showing documentation for functions/macros
  • [IEx.Helpers] Improve formatting of behaviours and typespecs by using the formatter
  • [IEx.Helpers] Allow pattern matching and guard expressions when on IEx.break!

Logger

  • [Logger] Add :discard_threshold to Logger to help with message queue overflow

Mix

  • [mix app.start] Add --preload-modules to mix app.start
  • [mix archive.build] Allow mix archive.build to bundle dot files via an option
  • [mix compile] Define a behavior for Mix compiler tasks and return diagnostics from compiler tasks
  • [mix compile] Track struct dependencies between files and recompile them only if the struct changes
  • [mix deps] Support :system_env option when specifying dependencies
  • [mix format] Add a mix format task that formats the given files (or the files specified in a .formatter.exs file)
  • [mix profile.eprof] Add a new task for time-based profiling with eprof
  • [mix test] Run all functions in a describe block by giving the file:line the describe block starts
  • [mix test] Report the top N slowest tests with the --slowest N flag
  • [mix test] Report the number of doctests and tests separately
  • [mix xref] Support --include-siblings in reports for umbrella support
  • [mix xref] Add mix xref graph --format stats
  • [mix xref] Add --only-nodes and --label filters to mix xref graph
  • [mix xref] Add mix xref deprecated that shows the callsite of deprecated functions

2. Bug fixes

Elixir

  • [CLI] Support path with spaces as argument to elixir.bat
  • [Inspect] Properly handle minus signal for non-decimal negative integers
  • [Integer] Do not raise on non-integer values in is_odd/is_even
  • [Kernel] Solve a precedence issue between & and |, such as [&Foo.bar/1 | &Baz.bat/2]
  • [Kernel] Do not load dynamic Elixir modules as :in_memory as this value is not officially supported by the code server. Instead, use an empty list, which is the same value used by Erlang.
  • [Kernel] Validate variable struct name is atom when used in pattern matching
  • [Kernel] No longer generate documentation for defdelegate functions automatically to avoid overriding previously specified @doc
  • [Macro] Fix Macro.to_string/2 for tuple calls, such as alias Foo.{Bar, Baz}
  • [MapSet] Return valid MapSet when unioning a legacy MapSet
  • [Regex] Return a leading empty space when splitting on empty pattern. This makes the split operation consistent with the other operations in the Regex module
  • [Stream] Ensure Stream.chunk_while/4 does not emit more elements than necessary when halted
  • [String] Return a leading empty space when splitting on empty string. This makes the split operation consistent with the other operations in the String module
  • [URI] Preserve empty fragments in URI.parse/1

Mix

  • [mix app.start] Improve the quality of reports if app fails to boot
  • [mix cmd] Allow mix cmd to be invoked multiple times without marking it as executed
  • [mix deps] Ensure optional dependencies in umbrella applications are loaded
  • [mix deps.update] Ensure transitive new non-Hex dependencies are also fetched when a repo is updated
  • [mix xref] Take compile dependencies with higher priority than runtime ones when building a graph
  • [mix xref] Handle external files for xref callers and warnings

3. Soft deprecations (no warnings emitted)

Elixir

  • [GenServer] Warn if init/1 is not defined in GenServer. This brings GenServer closer to the implementation in OTP and aligns all behaviours to require the init/1 callback
  • [Inspect.Algebra] surround/3 and surround_many/6 are deprecated in favor of container_doc/6
  • [Kernel] Specifying map types with variable keys without defining the type as required/optional is deprecated
  • [Kernel.ParallelCompiler] files/2 and files_to_path/3 are deprecated in favor of compile/2 and compile_to_path/3
  • [Kernel.ParallelRequire] files/2 is deprecated in favor of Kernel.ParallelCompiler.require/2
  • [Supervisor] The :simple_one_for_one strategy is deprecated in favor of DynamicSupervisor
  • [Supervisor] Passing a list of args to Supervisor.start_child/2 is deprecated in favor of DynamicSupervisor
  • [Task.Supervisor] Passing :restart and :shutdown to Task.Supervisor.start_link/2 is deprecated (it should be passed on start child instead)

ExUnit

  • [ExUnit.Formatter] :case_started and :case_finished events are deprecated in favor of :module_started and :module_finished

Mix

  • [Mix.Compilers.Erlang] Returning {:ok, val} | :error from custom Erlang compilers is deprecated in favor of {:ok, val, warnings} | {:error, errors, warnings}

4. Deprecations

Elixir

  • [Enum] Enum.partition/2 is deprecated in favor of Enum.split_with/2
  • [Keyword] Keyword.replace/3 is deprecated in favor of Keyword.fetch/2 and Keyword.put/3
  • [Map] Map.replace/3 is deprecated in favor of Map.fetch/2 and Map.put/3
  • [Macro] Macro.unescape_tokens/1 and Macro.unescape_tokens/2 are deprecated in favor of Enum.map/2
  • [Range] Deprecate Range.range?/1 in favor of pattern matching on _ .. _