Skip to content

Releases: elixir-lang/elixir

v1.16.0-rc.1

12 Dec 11:43
Compare
Choose a tag to compare
v1.16.0-rc.1 Pre-release
Pre-release

1. Enhancements

Elixir

  • [Code] Add :emit_warnings for Code.string_to_quoted/2
  • [File] Add :offset option to File.stream!/2
  • [Kernel] Auto infer size of matched variable in bitstrings
  • [Kernel] Preserve column information when translating typespecs
  • [String] Add String.replace_invalid/2

Logger

  • [Logger] Add Logger.levels/0

Mix

  • [mix archive.install] Support --sparse option
  • [mix compile.app] Warn if both :applications and :extra_applications are used
  • [mix compile.elixir] Pass original exception down to diagnostic :details when possible
  • [mix deps.clean] Emit a warning instead of crashing when a dependency cannot be removed
  • [mix escript.install] Support --sparse option
  • [mix release] Include include/ directory in releases

2. Bug fixes

Elixir

  • [Code] Keep quotes for atom keys in formatter
  • [Macro] Address exception on Macro.to_string/1 for certain ASTs
  • [Module] Make sure file and position information is included in several module warnings (regression)
  • [Path] Lazily evaluate File.cwd!/0 in Path.expand/1 and Path.absname/1

IEx

  • [IEx.Pry] Fix prying functions with only literals in their body

Mix

  • [mix archive.install] Restore code paths after archive.install
  • [mix escript.install] Restore code paths after escript.install

v1.16.0-rc.0

31 Oct 08:29
Compare
Choose a tag to compare
v1.16.0-rc.0 Pre-release
Pre-release

Code snippets in diagnostics

Elixir v1.15 introduced a new compiler diagnostic format and the ability to print multiple error diagnostics per compilation (in addition to multiple warnings).

With Elixir v1.16, we also include code snippets in exceptions and diagnostics raised by the compiler. For example, a syntax error now includes a pointer to where the error happened:

** (SyntaxError) invalid syntax found on lib/my_app.ex:1:17:
    error: syntax error before: '*'
    │
  1 │ [1, 2, 3, 4, 5, *]
    │                 ^
    │
    └─ lib/my_app.ex:1:17

For mismatched delimiters, it now shows both delimiters:

** (MismatchedDelimiterError) mismatched delimiter found on lib/my_app.ex:1:18:
    error: unexpected token: )
    │
  1 │ [1, 2, 3, 4, 5, 6)
    │ │                └ mismatched closing delimiter (expected "]")
    │ └ unclosed delimiter
    │
    └─ lib/my_app.ex:1:18

Errors and warnings diagnostics also include code snippets. When possible, we will show precise spans, such as on undefined variables:

  error: undefined variable "unknown_var"
  │
5 │     a - unknown_var
  │         ^^^^^^^^^^^
  │
  └─ lib/sample.ex:5:9: Sample.foo/1

Otherwise the whole line is underlined:

error: function names should start with lowercase characters or underscore, invalid name CamelCase
  │
3 │   def CamelCase do
  │   ^^^^^^^^^^^^^^^^
  │
  └─ lib/sample.ex:3

A huge thank you to Vinícius Muller for working on the new diagnostics.

Revamped documentation

Elixir's Getting Started guided has been made part of the Elixir repository and incorporated into ExDoc. This was an opportunity to revisit and unify all official guides and references.

We have also incorporated and extended the work on Understanding Code Smells in Elixir Functional Language, by Lucas Vegi and Marco Tulio Valente, from ASERG/DCC/UFMG, into the official document in the form of anti-patterns. The anti-patterns are divided into four categories: code-related, design-related, process-related, and meta-programming. Our goal is to give all developers examples of potential anti-patterns, with context and examples on how to improve their codebases.

Another ExDoc feature we have incorporated in this release is the addition of cheatsheets, starting with a cheatsheet for the Enum module. If you would like to contribute future cheatsheets to Elixir itself, feel free to start a discussion with an issue.

Finally, we have started enriching our documentation with Mermaid.js diagrams. You can find examples in the GenServer and Supervisor docs.

v1.16.0-rc.0 (2023-10-31)

1. Enhancements

EEx

  • [EEx] Include relative file information in diagnostics

Elixir

  • [Code] Automatically include columns in parsing options
  • [Code] Introduce MismatchedDelimiterError for handling mismatched delimiter exceptions
  • [Code.Fragment] Handle anonymous calls in fragments
  • [Code.Formatter] Trim trailing whitespace on heredocs with \r\n
  • [Kernel] Suggest module names based on suffix and casing errors when the module does not exist in UndefinedFunctionError
  • [Kernel.ParallelCompiler] Introduce Kernel.ParallelCompiler.pmap/2 to compile multiple additional entries in parallel
  • [Kernel.SpecialForms] Warn if True/False/Nil are used as aliases and there is no such alias
  • [Macro] Add Macro.compile_apply/4
  • [Module] Add support for @nifs annotation from Erlang/OTP 25
  • [Module] Add support for missing @dialyzer configuration
  • [String] Update to Unicode 15.1.0
  • [Task] Add :limit option to Task.yield_many/2

Mix

  • [mix] Add MIX_PROFILE to profile a list of comma separated tasks
  • [mix compile.elixir] Optimize scenario where there are thousands of files in lib/ and one of them is changed
  • [mix test] Allow testing multiple file:line at once, such as mix test test/foo_test.exs:13 test/bar_test.exs:27

2. Bug fixes

Elixir

  • [Code.Fragment] Fix crash in Code.Fragment.surround_context/2 when matching on ->
  • [IO] Raise when using IO.binwrite/2 on terminated device (mirroring IO.write/2)
  • [Kernel] Do not expand aliases recursively (the alias stored in Macro.Env is already expanded)
  • [Kernel] Ensure dbg module is a compile-time dependency
  • [Kernel] Warn when a private function or macro uses unquote/1 and the function/macro itself is unused
  • [Kernel] Do not define an alias for nested modules starting with Elixir. in their definition
  • [Kernel.ParallelCompiler] Consider a module has been defined in @after_compile callbacks to avoid deadlocks
  • [Path] Ensure Path.relative_to/2 returns a relative path when the given argument does not share a common prefix with cwd

ExUnit

  • [ExUnit] Raise on incorrectly dedented doctests

Mix

  • [Mix] Ensure files with duplicate modules are recompiled whenever any of the files change

3. Soft deprecations (no warnings emitted)

Elixir

  • [File] Deprecate File.stream!(file, options, line_or_bytes) in favor of keeping the options as last argument, as in File.stream!(file, line_or_bytes, options)
  • [Kernel.ParallelCompiler] Deprecate Kernel.ParallelCompiler.async/1 in favor of Kernel.ParallelCompiler.pmap/2
  • [Path] Deprecate Path.safe_relative_to/2 in favor of Path.safe_relative/2

4. Hard deprecations

Elixir

  • [Date] Deprecate inferring a range with negative step, call Date.range/3 with a negative step instead
  • [Enum] Deprecate passing a range with negative step on Enum.slice/2, give first..last//1 instead
  • [Kernel] ~R/.../ is deprecated in favor of ~r/.../. This is because ~R/.../ still allowed escape codes, which did not fit the definition of uppercase sigils
  • [String] Deprecate passing a range with negative step on String.slice/2, give first..last//1 instead

ExUnit

  • [ExUnit.Formatter] Deprecate format_time/2, use format_times/1 instead

Mix

  • [mix compile.leex] Require :leex to be added as a compiler to run the leex compiler
  • [mix compile.yecc] Require :yecc to be added as a compiler to run the yecc compiler

v1.15.7

14 Oct 10:30
Compare
Choose a tag to compare

1. Enhancements

Elixir

  • [Elixir] Allow code evaluation across Elixir versions

2. Bug fixes

EEx

  • [EEx] Do not emit duplicate warnings from tokenizer

Mix

  • [mix format] Correctly match file to subdirectory in Mix.Tasks.Format.formatter_for_file/2

v1.15.6

20 Sep 09:00
Compare
Choose a tag to compare

This release also includes fixes to the Windows installer.

1. Bug fixes

EEx

  • [EEx] Do not crash when printing tokenizer warnings

Elixir

  • [Code] Fix formatter for nested * in bitstrings
  • [Code] Improve feedback when an invalid block is given Code.quoted_to_algebra/2
  • [Kernel] Trace functions before they are inlined

Mix

  • [mix compile] Ensure :extra_applications declare in umbrella projects are loaded
  • [mix deps.get] Do not check for invalid applications before deps.get
  • [mix deps.update] Do not check for invalid applications before deps.update
  • [mix format] Load plugins when invoking the formatter from an IDE

v1.15.5

28 Aug 12:50
Compare
Choose a tag to compare

1. Enhancements

IEx

  • [IEx.Autocomplete] Speed up loading of struct suggestions

2. Bug fixes

Elixir

  • [Code.Fragment] Fix Code.Fragment.surround_context/2 for aliases and submodules of non-aliases
  • [Kernel] Ensure stacktrace is included when necessary when rescuing multiple exceptions in the same branch
  • [Kernel] Fix index in error message for unused optional arguments

ExUnit

  • [ExUnit.Diff] Fix scenario where diff would not show up due to a timed-out loop

IEx

  • [IEx] Force group leader to run as a binary and unicode in IEx

Mix

  • [mix compile] Do not assume blake is always available
  • [mix format] Load and compile plugins if specified in subdirectories

v1.15.4

18 Jul 11:13
Compare
Choose a tag to compare

1. Bug fixes

Mix

  • [mix archive.build] Disable protocol consolidation when building archiveson archive.install
  • [mix compile] Track removed files per local dependency (this addresses a bug where files depending on modules from path dependencies always recompiled)
  • [mix release] Do not strip relevant chunks from Erlang/OTP 26

v1.15.3

15 Jul 07:59
Compare
Choose a tag to compare

1. Enhancements

Elixir

  • [Kernel] Improve better stacktraces when executing unnested Elixir code in a file

Mix

  • [Mix] Allow to opt out of starting apps in Mix.install/2

2. Bug fixes

Elixir

  • [Code] Ensure with_diagnostics propagate warnings from inner Erlang passes

IEx

  • [IEx] Fix --remsh on Erlang/OTP 25 and earlier

Mix

  • [mix compile.elixir] Ensure __mix_recompile__? callbacks are properly invoked

v1.15.2

01 Jul 20:27
Compare
Choose a tag to compare

1. Bug fixes

IEx

  • [IEx] Fix CLI being unable to boot on Windows

v1.15.1

30 Jun 16:20
Compare
Choose a tag to compare

1. Enhancements

  • [Code] Code.string_to_quoted/2 honors :static_atoms_encoder for multi-letter sigils

2. Bug fixes

ExUnit

  • [ExUnit.CaptureLog] Fix race condition on concurrent capture_log
  • [ExUnit.CaptureLog] Respect options passed to nested capture_log calls
  • [ExUnit.Doctest] Properly compile doctests without results terminated by fences
  • [ExUnit.Doctest] Allow variables defined in doctests to be used in expectation

IEx

  • [IEx] Ensure pry works on Erlang/OTP 25 and earlier while IEx is booting
  • [IEx] Code.Fragment.surround_context considers surround context around spaces and parens

Logger

  • [Logger] Do not assume Logger has been loaded at compile-time
  • [Logger.Formatter] Properly handle :function as metadata

Mix

  • [mix compile] Ensure the current project is available on the code path after its Elixir sources are compiled
  • [mix compile] Guarantee yecc/leex are available when emitting warnings from previous runs
  • [mix compile] Fix bug where an external resource was deleted after its
    mtime was successfully retrieved
  • [mix compile] Track removed modules and exports across local deps
  • [mix deps] Fix an issue where dependencies could not be started in an umbrella projects
  • [mix release] Properly handle optional dependencies when there is a conflict in the application start mode
  • [mix release] Remove --werl from release scripts on Erlang/OTP 26

v1.15.0

19 Jun 11:46
Compare
Choose a tag to compare

Official announcement: https://elixir-lang.org/blog/2023/06/19/elixir-v1-15-0-released/

1. Enhancements

EEx

  • [EEx] Include source code snippets in syntax errors

Elixir

  • [Calendar] Add support for epoch time (%s) to Calendar.strftime/2
  • [Code] Code.format_string!/2 now converts 'charlists' into ~c"charlists" by default
  • [Code] Add :on_undefined_variable to the compiler options to preserve the warning behaviour which was deprecated back in Elixir v1.4
  • [Code] Add Code.loaded?/1 and Code.ensure_all_loaded(!)/1
  • [Code] Add Code.prepend_paths/1, Code.append_paths/1, and Code.delete_paths/1
  • [Code] Add Code.with_diagnostics/2 to return diagnostics when compiling and evaluating code
  • [Code.Fragment] Support nested expressions in Code.Fragment.cursor_context/1
  • [Code.Fragment] Keep operators and no paren calls in Code.Fragment.container_cursor_to_quoted/1
  • [Date] Add Date.before?/2 and Date.after?/2
  • [DateTime] Add DateTime.before?/2 and DateTime.after?/2
  • [DateTime] Support precision in DateTime.utc_now/2
  • [File] Support distributed File.Stream
  • [Inspect] Inspect now renders 'charlists' as ~c"charlists" by default
  • [Kernel] Break down case and cond inside dbg/2
  • [Kernel] Add t:nonempty_binary/0 and t:nonempty_bitstring/0
  • [Kernel] Treat @behaviours as runtime dependencies
  • [Kernel] Do not add runtime dependencies for alias references in patterns and guards
  • [Kernel] Warn for nested calls without parens inside keywords
  • [Kernel] Support for multi-letter uppercase sigils
  • [Kernel] Introduce mechanism to collect several errors in a module. Previously, as soon as there was a compilation error, compilation would fail. Now the compiler became a bit smarter and will report multiple errors whenever possible as multiple error: ... messages, similar to warning: ...
  • [Kernel] Raise instead of warning on undefined variables. Previously, an undefined variable would attempt to invoke a function of the same name, which led to confusing error messages, especially to newcomers. To enable the previous behaviour, invoke Code.compiler_options(on_undefined_variable: :warn) at the top of your mix.exs
  • [Kernel.CLI] Support --sname undefined/--name undefined so a name is automatically generated
  • [Keyword] Add Keyword.split_with/2
  • [Macro] Improve error message when piping into an expression ending in bracket-based access
  • [Macro.Env] Add Macro.Env.lookup_alias_as/2
  • [Map] Add Map.split_with/2
  • [Map] Add Map.intersect/2 and Map.intersect/3
  • [MapSet] Add MapSet.split_with/2
  • [MapSet] Optimize most functions
  • [NaiveDateTime] Add NaiveDateTime.beginning_of_day/1 and NaiveDateTime.end_of_day/1
  • [NaiveDateTime] Add NaiveDateTime.before?/2 and NaiveDateTime.after?/2
  • [NaiveDateTime] Support precision in NaiveDateTime.utc_now/2
  • [Module] Mark functions as generated in "Docs" chunk
  • [Module] Add Module.get_last_attribute/3
  • [OptionParser] Support :return_separator option
  • [Process] Add Process.alias/0,1 and Process.unalias/1
  • [Range] Add Range.split/2
  • [String] Update Unicode to version 15.0.0
  • [String] Add :fast_ascii mode to String.valid?/2
  • [Supervisor] Add support for automatic shutdown in Supervisor
  • [System] Support :lines in System.cmd/3 to capture output line by line
  • [Task] Remove head of line blocking on Task.yield_many/2
  • [Task] Enable selective receive optimizations in Erlang/OTP 26+
  • [Task] Reduce tasks footprint by avoiding unecessary work during spawning
  • [Task.Supervisor] Do not copy args on temporary Task.Supervisor.start_child/2
  • [Time] Add Time.before?/2 and Time.after?/2
  • [URI] Add URI.append_path/2

ExUnit

  • [ExUnit] Add more color configuration to ExUnit CLI formatter
  • [ExUnit.Callbacks] Accept {module, function} tuples in ExUnit setup callbacks
  • [ExUnit.Case] Add ExUnit.Case.get_last_registered_test/1
  • [ExUnit.Doctest] Add ExUnit.DocTest.doctest_file/2
  • [ExUnit.Doctest] Include doctest_data in doctest tags
  • [ExUnit.Formatter] When comparing two anonymous functions, defined at the same place but capturing a different environment, we will now also diff the environments

IEx

  • [IEx] Make pry opt-in on dbg with --dbg pry
  • [IEX] Support IEX_HOME
  • [IEx.Autocomplete] Only provide aliases when autocompleting alias, import, and require
  • [IEx.Autocomplete] Provide field completion on map and struct updates
  • [IEx.Helpers] Add runtime_info(:allocators)
  • [IEx.Info] Implement protocol for Range, DateTime, and Regex

Logger

  • [Logger] Add Logger.add_handlers/1 and Logger.default_formatter/1
  • [Logger] Introduce default_formatter and default_handler configuration for Logger which configures Erlang/OTP logger
  • [Logger] Add :always_evaluate_messages configuration to Logger
  • [Logger.Formatter] Implement the Erlang Logger formatter API
  • [Logger.Formatter] Add support for ports in Logger metadata

Mix

  • [mix app.start] Allow applications to be started concurrently via the :start_concurrently configuration
  • [mix compile] Set --all-warnings by default
  • [mix compile] Reduce the amount of filesystem lookups for path dependencies by storing timestamps in manifests
  • [mix compile] Track digests of @external_resources
  • [mix compile.app] Write optional_applications to .app file
  • [mix compile.elixir] Add --purge-consolidation-path-if-stale which will purge the given consolidation path if compilation is required
  • [mix deps.compile] Automatically recompile dependencies if their compile env changes
  • [mix deps.get] Automatically install Hex and Rebar on mix deps.get/mix deps.update
  • [mix deps.get] Support --check-locked which raises if changes to the lockfile are required
  • [mix eval] Allow passing additional arguments
  • [mix format] Support --no-exit option
  • [mix format] Allow multiple formatters per file extension and sigil
  • [mix format] Show diffs whenever --check-formatted fails
  • [mix format] Allow the formatting root to be configured
  • [mix loadpaths] Cache deps and archive loadpaths in Erlang/OTP 26
  • [mix profile.fprof] Support --trace-to-file to improve performance when working with large outputs
  • [mix release] Allow passing additional arguments to the eval command
  • [mix xref graph] Support --output flag
  • [Mix.Project] Support def cli to unify all CLI defaults in a single place
  • [Mix.Project] Add Mix.Project.deps_tree/1

2. Bug fixes

Elixir

  • [Code.Formatter] Fix a scenario where a keyword followed by parenthesis could go above the maximum line length
  • [Code.Formatter] Remove unnecessary parens in nullary type funs
  • [Exception] Fix operator precedence when printing guards in Exception.blame/3
  • [File] Do not raise if there are file system race conditions in File.cp/2
  • [File] Do not raise when deleting write-only empty directories on File.rm_rf/1
  • [Kernel] Expand macros on the left side of -> in try/rescue
  • [Kernel] Raise on misplaced ... inside typespecs
  • [Kernel] Do not import behaviour_info and module_info functions from Erlang modules
  • [Kernel] Raise when macros are given to dialyzer
  • [Kernel.ParallelCompiler] Make sure compiler doesn't crash when there are stray messages in the inbox
  • [Kernel.ParallelCompiler] Track compile and runtime warnings separately
  • [Module] Ensure that Module.get_attribute/3 returns nil and not the given default value when an attribute has been explicitly set as nil
  • [System] Fix race condition when a script would terminate before System.stop/1 executes
  • [Task] Do not double log Task failure reports
  • [URI] Make sure URI.merge/2 works accordingly with relative paths

ExUnit

  • [ExUnit] Fix crash when @tag capture_log: true was set to true and the Logger application was shut down in the middle of the test
  • [ExUnit] Do not merge context as tags inside the runner to reduce memory usage when emitting events to formatters
  • [ExUnit] Mark test cases as invalid when an exit occurs during setup_all
  • [ExUnit] Do not expand or collect vars from quote in ExUnit assertions
  • [ExUnit.DocTest] Ensure proper line is returned when failing to parse doctest results
  • [ExUnit.Doctest] Fix line information when a doctest with multiple assertions fails

IEx

  • [IEx] Do not spawn a process to read IO. This fixes a bug where multiline paste stopped working
    whenever the input reader was killed
  • [IEx] Do not perform completion for prompts triggered during code evaluation

Mix

  • [mix compile] Include cwd in compiler cache key
  • [mix release] Fix Windows service when invoking erlsrv.exe in path with spaces
  • [mix xref] Raise early if mix xref is used at the umbrella root

3. Soft deprecations (no warnings emitted)

Elixir

  • [File] File.cp/3 and File.cp_r/3 with a function as third argument
    is deprecated in favor of a keyword list
  • [Kernel] Require pin variable when accessing variable inside binary size in match
  • [Kernel.ParallelCompiler] Require the :return_diagnostics option to be
    set to true when compiling or requiring code

Logger

  • [Logger] add_backend/2, remove_backend/2, and configure_backend/2 have been deprecated
    in favor of the new :logger_backends dependency
  • [Logger] The :console configuration has been deprecated in favor of :default_formatter
  • [Logger] The :backends configuration has been deprecated in favor of Logger.add_handlers/1

Mix

  • [Mix.Project] :preferred_cli_env is deprecated in favor o...
Read more