Releases: elixir-lang/elixir
v1.18.2
1. Enhancements
Elixir
- [CLI] Add
--color/--no-colorfor enabling and disabling of ANSI colors - [Code.Fragment] Provide more AST context when invoking
container_cursor_to_quotedwith trailing fragments - [Regex] Ensure compatibility with Erlang/OTP 28+ new Regex engine
Mix
- [mix] Print compilation lock waiting message to stderr
- [mix] Add an environment variable to optionally disable compilation locking
2. Bug fixes
Elixir
- [CLI] Temporarily remove PowerShell scripts for
elixir,elixirc, andmixon Windows, as they leave the shell broken after quitting Erlang
ExUnit
- [ExUnit] Fix crash when diffing bitstring specifiers
IEx
- [IEx.Autocomplete] Fix crashing whhen autocompleting structs with runtime values
Mix
- [mix] Track compilation locks per user to avoid permission errors
- [mix deps.update] Ensure Git dependencies can be upgraded by doing so against the origin
v1.18.1
1. Enhancements
- [Kernel] Do not emit type violation warnings when comparing or matching against literals
- [Kernel] Do not validate clauses of private overridable functions
2. Bug fixes
Elixir
- [Code.Fragment] Ensure
Code.Fragment.container_cursor_to_quoted/2with:trailing_fragmentparses expressions that were supported in previous versions - [Kernel] Do not crash when typing violation is detected on dynamic dispatch
- [Kernel] Properly annotate the source for warnings emitted by the compiler with the
@fileannotation - [Kernel] Properly annotate the source for warnings emitted by the type system with the
@fileannotation - [Kernel] Remove
:no_parensmetadata when using capture with arity on all cases - [Kernel] Ensure diagnostic traces are kept backwards compatible
ExUnit
- [ExUnit.Case] Ensure async groups do not run concurrenly while the test suite is still loading
- [ExUnit.Case] Ensure
--repeat-until-failurecan be combined with groups
Mix
- [mix compile.elixir] Store compilation results if compilation fails due to
--warnings-as-errors - [mix deps.loadpaths] Add build lock
- [mix escript.build] Ensure build succeeds when protocol consolidation is disabled
- [Mix.Shell] Ensure encoding is properly respected on Windows and Unix systems
v1.18.0
Official announcement: https://elixir-lang.org/blog/2024/12/19/elixir-v1-18-0-released/
1. Enhancements
Elixir
- [CLI] Add experimental PowerShell scripts for
elixir,elixirc, andmixon Windows. Those provide a safer entry point for running Elixir from other platforms - [Calendar] Add
Duration.to_string/1 - [Code] Support several migration options in
Code.format_string!/2 - [Code] Add parenthesis around
--and---inCode.format_string!/2to make precedence clearer - [Code] Include more metadata in
Code.string_to_quoted/2whentoken_metadata: trueto help compute ranges from the AST - [Code.Fragment] Have
:capture_argas its own entry inCode.Fragment.surround_context/2 - [Config] Add
Config.read_config/1 - [Enumerable] Add
Enum.product_by/2andEnum.sum_by/2 - [Exception] Add
MissingApplicationsErrorexception to denote missing applications - [JSON] Add a new
JSONmodule with encoding and decoding functionality - [JSON] Implement
JSON.Encoderfor all Calendar types - [Kernel] Update source code parsing to match UTS #55 latest recommendations. In particular, mixed script is allowed in identifiers as long as they are separate by underscores (
_), such ashttp_сервер. Previously allowed highly restrictive identifiers, which mixed Latin and other scripts, such as the japanese word for t-shirt,Tシャツ, now require the underscore as well - [Kernel] Warn on bidirectional confusability in identifiers
- [Kernel] Verify the type of the binary generators
- [Kernel] Track the type of tuples in patterns and inside
elem/2 - [Kernel] Perform validation of root AST nodes in
unquoteandunquote_splicingto catch bugs earlier - [Kernel] Add source, behaviour, and record information to Docs chunk metadata
- [Kernel] Support deterministic builds in tandem with Erlang by setting
ERL_COMPILER_OPTIONS=deterministic. Keep in mind deterministic builds strip source and other compile time information, which may be relevant for programs - [Kernel] Allow aliases and imports to be enabled conditionally in module body
- [List] Add
List.ends_with?/2 - [Macro] Improve
dbghandling ofif/2,with/1and of code blocks - [Macro] Add
Macro.struct_info!/2to return struct information mirroringmod.__info__(:struct) - [Registry] Add
Registry.lock/3for local locking - [PartitionSupervisor] Add
PartitionSupervisor.resize!/2to resize the number of partitions in a supervisor (up to the limit it was started with) - [Process] Handle arbitrarily high integer values in
Process.sleep/1 - [Protocol] Add
@undefined_impl_descriptionto customize error message when an implementation is undefined - [Protocol] Add
__deriving__/1as optional macro callback toProtocol, no longer requiring empty implementations - [String] Inspect special whitespace and zero-width characters using their Unicode representation
- [String] Update Unicode to 16.0
ExUnit
- [ExUnit] Support parameterized tests on
ExUnit.Case - [ExUnit] Support test groups: tests in the same group never run concurrently
- [ExUnit.Case] Add
test_pidas a tag
IEx
- [IEx] Add
IEx.configure(auto_reload: true)to automatically pick up modules recompiled from other operating system processes - [IEx] Add
:dot_iexsupport toIEx.configure/1 - [IEx] Add report for normal/shutdown exits in IEx
Mix
- [mix compile] Ensure only a single operating system process can compile at a given time
- [mix deps.get] Ensure only a single operating system process can fetch deps at a given time
- [mix format] Add
mix format --migrateto migrate from deprecated functionality - [mix format] Add new options and metadata to improve formatting applying by editors and other environments
- [mix test] Taint failure manifest if requiring or compiling tests fail
- [Mix.Project] Add a
:listenersconfiguration to listen to compilation events from the current and other operating system processes - [Mix.Task.Compiler] Add API for fetching all persisted compiler diagnostics
- [Mix.Task.Compiler] Add API for fetching all compiler tasks
2. Bug fixes
Elixir
- [Code] Fix delimiter metadata for single quoted atoms and remote calls in
Code.string_to_quoted/2 - [Code.Formatter] Fix formatter adding extra escapes to quoted remote calls
- [Code.Fragment] Properly handle keyword keys as their own entry
- [Inspect.Algebra] Ensure
next_break_fitsrespectsline_length - [Kernel] Validate AST on
unquoteandunquote_splicingto provide better error reports instead of failing too late inside the compiler - [Kernel] Avoid crashes when emitting diagnostics on code using \t for indentation
- [Module] Include module attribute line and name when tracing its aliases
- [Stream] Do not halt streams twice in
Stream.transform/5 - [URI] Fix a bug when a schemaless URI is given to
URI.merge/2
ExUnit
- [ExUnit.Assertions] Raise if guards are used in
assert/1with= - [ExUnit.Assertions] Format inserted/deleted maps in list assertions
IEx
- [IEx.Helpers]
IEx.Helpers.recompile/0will reload modules changed by other operating system processes
Mix
- [mix compile] Ensure warnings from external resources are emitted with
--all-warningswhen files do not change - [mix deps.compile] Fix escaping issues when invoking
rebar3in some cases - [mix escript] Fix escript layout and support storing
privdirectories - [mix release] Make
.appfiles deterministic in releases - [Mix.Shell] Fix
Mix.Shellon Windows when outputting non UTF-8 characters
3. Soft deprecations (no warnings emitted)
Elixir
- [Inspect.Algebra]
color/3is deprecated in favor ofcolor_doc/3 - [Inspect.Algebra]
fold_doc/2is deprecated in favor offold/2 - [Kernel] Deprecate
unlessin favor ofif. Usemix format --migrateto automate the migration - [Macro]
Macro.struct!/2is deprecated in favor ofMacro.struct_info!/2 - [Protocol] Defining
__deriving__/3inside theAnyimplementation is deprecated, derive it inside the protocol definition itself
4. Hard deprecations
EEx
- [EEx]
<%#is deprecated in favor of<%!--or<% # - [EEx]
c:EEx.handle_text/2is deprecated in favor ofc:EEx.handle_text/3
Elixir
- [Code] Setting
:warnings_as_errorsis deprecated viaCode.put_compiler_option/2. This must not affect developers, as the:warnings_as_errorsoption is managed by Mix tasks, and not directly used via theCodemodule - [Enumerable] Deprecate returning a two-arity function in
Enumerable.slice/1 - [List]
List.zip/1is deprecated in favor ofEnum.zip/1 - [Module] Deprecate
Module.eval_quoted/3in favor ofCode.eval_quoted/3 - [Range] Deprecate inferring negative ranges on
Range.new/2 - [Tuple]
Tuple.append/2is deprecated, useTuple.insert_at/3instead
Mix
- [mix cmd] Deprecate
mix cmd --app APPin favor ofmix do --app APP - [mix compile]
:warnings_as_errorsconfiguration in:elixirc_optionsis deprecated. Instead pass the--warnings-as-errorsflag tomix compile. Alternatively, you might alias the task:aliases: [compile: "compile --warnings-as-errors"] - [mix test]
:warnings_as_errorsconfiguration in:test_elixirc_optionsis deprecated. Instead pass the--warnings-as-errorsflag tomix test. Alternatively, you might alias the task:aliases: [test: "test --warnings-as-errors"] - [Mix.Tasks.Compile] Deprecate
compilers/0in favor ofMix.Task.Compiler.compilers/0
v1.17
The CHANGELOG for v1.17 releases can be found in the v1.17 branch.
v1.18.0-rc.0
1. Enhancements
Elixir
- [CLI] Add experimental PowerShell scripts for
elixir,elixirc, andmixon Windows. Those provide a safer entry point for running Elixir from other platforms - [Calendar] Add
Duration.to_string/1 - [Code] Support several migration options in
Code.format_string!/2 - [Code] Add parenthesis around
--and---inCode.format_string!/2to make precedence clearer - [Code] Include more metadata in
Code.string_to_quoted/2whentoken_metadata: trueto help compute ranges from the AST - [Code.Fragment] Have
:capture_argas its own entry inCode.Fragment.surround_context/2 - [Config] Add
Config.read_config/1 - [Enumerable] Add
Enum.product_by/2andEnum.sum_by/2 - [Exception] Add
MissingApplicationsErrorexception to denote missing applications - [Kernel] Update source code parsing to match UTS #55 latest recommendations. In particular, mixed script is allowed in identifiers as long as they are separate by underscores (
_), such ashttp_сервер. Previously allowed highly restrictive identifiers, which mixed Latin and other scripts, such as the japanese word for t-shirt,Tシャツ, now require the underscore as well - [Kernel] Warn on bidirectional confusability in identifiers
- [Kernel] Verify the type of the binary generators
- [Kernel] Track the type of tuples in patterns and inside
elem/2 - [Kernel] Perform validation of root AST nodes in
unquoteandunquote_splicingto catch bugs earlier - [Kernel] Add source, behaviour, and record information to Docs chunk metadata
- [Kernel] Support deterministic builds in tandem with Erlang by setting
ERL_COMPILER_OPTIONS=deterministic. Keep in mind deterministic builds strip source and other compile time information, which may be relevant for programs - [Kernel] Allow aliases and imports to be enabled conditionally in module body
- [List] Add
List.ends_with?/2 - [Macro] Improve
dbghandling ofif/2,with/1and of code blocks - [Macro] Add
Macro.struct_info!/2to return struct information mirroringmod.__info__(:struct) - [Registry] Add
Registry.lock/3for local locking - [PartitionSupervisor] Add
PartitionSupervisor.resize!/2to resize the number of partitions in a supervisor (up to the limit it was started with) - [Process] Handle arbitrarily high integer values in
Process.sleep/1 - [Protocol] Add
@undefined_impl_descriptionto customize error message when an implementation is undefined - [Protocol] Add
__deriving__/1as optional macro callback toProtocol, no longer requiring empty implementations - [String] Inspect special whitespace and zero-width characters using their Unicode representation
- [String] Update Unicode to 16.0
ExUnit
- [ExUnit] Support parameterized tests on
ExUnit.Case - [ExUnit] Support test groups: tests in the same group never run concurrently
- [ExUnit.Case] Add
test_pidas a tag
IEx
- [IEx] Add
:dot_iexsupport toIEx.configure/1 - [IEx] Add report for normal/shutdown exits in IEx
Mix
- [mix compile] Ensure only a single operating system process can compile at a given time
- [mix deps.get] Ensure only a single operating system process can fetch deps at a given time
- [mix format] Add
mix format --migrateto migrate from deprecated functionality - [mix format] Add new options and metadata to improve formatting applying by editors and other environments
- [mix test] Taint failure manifest if requiring or compiling tests fail
- [Mix.Project] Add a
:listenersconfiguration to listen to compilation events from the current and other operating system processes - [Mix.Task.Compiler] Add API for fetching all persisted compiler diagnostics
- [Mix.Task.Compiler] Add API for fetching all compiler tasks
2. Bug fixes
Elixir
- [Code] Fix delimiter metadata for single quoted atoms and remote calls in
Code.string_to_quoted/2 - [Code.Formatter] Fix formatter adding extra escapes to quoted remote calls
- [Code.Fragment] Properly handle keyword keys as their own entry
- [Inspect.Algebra] Ensure
next_break_fitsrespectsline_length - [Kernel] Validate AST on
unquoteandunquote_splicingto provide better error reports instead of failing too late inside the compiler - [Module] Include module attribute line and name when tracing its aliases
- [Stream] Do not halt streams twice in
Stream.transform/5 - [URI] Fix a bug when a schemaless URI is given to
URI.merge/2
ExUnit
- [ExUnit.Assertions] Raise if guards are used in
assert/1with= - [ExUnit.Assertions] Format inserted/deleted maps in list assertions
IEx
- [IEx.Helpers]
IEx.Helpers.recompile/0will reload modules changed by other operating system processes
Mix
- [mix compile] Ensure warnings from external resources are emitted with
--all-warningswhen files do not change - [mix deps.compile] Fix escaping issues when invoking
rebar3in some cases - [mix escript] Fix escript layout and support storing
privdirectories - [mix release] Make
.appfiles deterministic in releases - [Mix.Shell] Fix
Mix.Shellon Windows when outputting non UTF-8 characters
3. Soft deprecations (no warnings emitted)
Elixir
- [Inspect.Algebra]
color/3is deprecated in favor ofcolor_doc/3 - [Inspect.Algebra]
fold_doc/2is deprecated in favor offold/2 - [Kernel] Deprecate
unlessin favor ofif. Usemix format --migrateto automate the migration - [Macro]
Macro.struct!/2is deprecated in favor ofMacro.struct_info!/2 - [Protocol] Defining
__deriving__/3inside theAnyimplementation is deprecated, derive it inside the protocol definition itself
4. Hard deprecations
EEx
- [EEx]
<%#is deprecated in favor of<%!--or<% # - [EEx]
c:EEx.handle_text/2is deprecated in favor ofc:EEx.handle_text/3
Elixir
- [Code] Setting
:warnings_as_errorsis deprecated viaCode.put_compiler_option/2. This must not affect developers, as the:warnings_as_errorsoption is managed by Mix tasks, and not directly used via theCodemodule - [Enumerable] Deprecate returning a two-arity function in
Enumerable.slice/1 - [List]
List.zip/1is deprecated in favor ofEnum.zip/1 - [Module] Deprecate
Module.eval_quoted/3in favor ofCode.eval_quoted/3 - [Range] Deprecate inferring negative ranges on
Range.new/2 - [Tuple]
Tuple.append/2is deprecated, useTuple.insert_at/3instead
Mix
- [mix cmd] Deprecate
mix cmd --app APPin favor ofmix do --app APP - [Mix.Tasks.Compile] Deprecate
compilers/0in favor ofMix.Task.Compiler.compilers/0
v1.17.3
1. Bug fixes
Elixir
- [Duration] Fix parsing of fractional durations with non-positive seconds
- [Kernel] Do not attempt to group module warnings when they have a large context
IEx
- [IEx.Helpers] Properly reconsolidate protocols on
recompile
Mix
- [mix compile.elixir] Do not verify modules twice
- [mix xref] Respect the
--labeloption on stats and cycles
v1.17.2
1. Bug fixes
Logger
- [Logger.Translator] Fix logger crash when
:gen_statem'sformat_status/2returns non-tuple
Mix
- [mix deps.get] Fix regression when fetching a git repository with a
:ref - [mix release] Validate
RELEASE_MODEand set ERRORLEVEL on.batscripts - [mix release] Fix invalid example in code comment inside the generated vm.args.eex
v1.17.1
1. Enhancements
Mix
- [mix compile.elixir] Do not run fixpoint computation on runtime dependencies. This should considerably improve compilation times for large projects when changing only one or two files
2. Bug fixes
EEx
- [EEx] Do not warn for assignment with blocks in EEx
Elixir
- [Kernel] Fix bug when using pinned variables inside
with'selsepatterns - [Kernel] Fix Dialyzer error when with else clause is calling a
no_returnfunction
ExUnit
- [ExUnit] Do not alternative sync/async suites on
--repeat-until-failure
v1.17.0
Official announcement: https://elixir-lang.org/blog/2024/06/12/elixir-v1-17-0-released/
1. Enhancements
Elixir
- [Access] Add
Access.find/1that mirrorsEnum.find/2 - [Code] Support cursor inside fn/rescue/catch/else/after inside
Code.Fragment.container_cursor_to_quoted/2 - [Date] Add
Date.shift/2to shift dates with duration and calendar-specific semantics - [Date] Allow
Dateto accept years outside of-9999..9999range - [DateTime] Add
DateTime.shift/2to shift datetimes with duration and calendar-specific semantics - [Duration] Add a new
Durationdata type - [GenServer] Add
c:GenServer.format_status/1callback - [Kernel] Add
Kernel.get_in/1with safe nil-handling for access and structs - [Kernel] Add
Kernel.is_non_struct_map/1guard - [Kernel] Add
Kernel.to_timeout/1 - [Kernel] Emit warnings for undefined functions from modules defined within the same context as the caller code
- [Kernel] Support integers in uppercase sigils
- [Keyword] Add
Keyword.intersect/2-3to mirror theMapAPI - [Macro] Add
Macro.Env.define_alias/4,Macro.Env.define_import/4,Macro.Env.define_require/4,Macro.Env.expand_alias/4,Macro.Env.expand_import/5, andMacro.Env.expand_require/6to aid the implementation of language servers and embedded languages - [NaiveDateTime] Add
NaiveDateTime.shift/2to shift naive datetimes with duration and calendar-specific semantics - [Process] Add
Process.set_label/1 - [String] Add
String.byte_slice/3to slice a string to a maximum number of bytes while keeping it UTF-8 encoded - [System] Support
use_stdio: falseinSystem.cmd/3andSystem.shell/2 - [Time] Add
Time.shift/2to shift times with duration and calendar-specific semantics
ExUnit
- [ExUnit] Propagate the test process itself as a caller in
start_supervised - [ExUnit] Include max cases in ExUnit reports
IEx
- [IEx.Helpers] Warns if
recompilewas called and the current working directory changed - [IEx.Helpers] Add
c/0as an alias tocontinue/0 - [IEx.Pry] Add
IEx.Pry.annotate_quoted/3to annotate a quoted expression with pry breakpoints
Logger
- [Logger] Format
:gen_statemreports using Elixir data structures - [Logger] Include process label in logger events
Mix
- [mix deps] Add
:depthoption toMix.SCM.Git, thus supporting shallow clones of Git dependencies - [mix deps] Warn if
:optionalis used in combination with:in_umbrella - [mix deps.get] Do not add optional dependency requirements if its parent dep was skipped
- [mix deps.tree] Add
--umbrella-onlytomix deps.tree - [mix profile.tprof] Add a new profiler, available on Erlang/OTP 27+, which can measure count, time, and heap usage
- [mix test] Add
mix test --breakpointsthat sets up a breakpoint before each test that will run - [mix test] Add
mix test --repeat-until-failureto rerun tests until a failure occurs - [mix test] Add
mix test --slowest-modulesto print slowest modules based on all of the tests they hold - [mix test] Generate cover HTML files in parallel
2. Bug fixes
Elixir
- [bin/elixir.bat] Improve handling of quotes and exclamation marks in flags
- [Code] Address a bug where AST nodes for
(a -> b)were not wrapped as part of the literal encoder - [Kernel] Resolve inconsistencies of how
..and...are handled at the AST level - [Kernel] Fix parsing precedence of ambiguous operators followed by containers
- [Kernel] Do not expand code in
quote bind_quoted: ...twice - [Kernel] Respect
:lineproperty when:fileis given as option toquote - [Kernel] Do not crash on
Macro.escape/2when passing a quote triplet without valid meta - [Kernel] Avoid double tracing events when capturing a function
- [Kernel] Fix a bug where captured arguments would conflict when a capture included a macro that also used captures
- [Module] Return default value in
Module.get_attribute/3for persisted attributes which have not yet been written to
IEx
- [IEx.Helpers] Update the history size whenever history is pruned
Mix
- [mix deps] Fix error message for diverged SCM definition in sibling
3. Soft deprecations (no warnings emitted)
Elixir
- [GenServer] Deprecate
c:GenServer.format_status/2callback to align with Erlang/OTP 25+
Mix
- [mix profile.cprof] Deprecated in favor of the new
mix profile.tprof - [mix profile.eprof] Deprecated in favor of the new
mix profile.tprof
4. Hard deprecations
Elixir
- [IO] Passing
:alltoIO.read/2andIO.binread/2is deprecated, pass:eofinstead - [Kernel] Single-quote charlists are deprecated, use
~cinstead - [Kernel] Deprecate escaping closing delimiter in uppercase sigils
- [Range]
left..rightwithout explicit steps inside patterns and guards is deprecated, writeleft..right//stepinstead - [Range] Decreasing ranges, such as
10..1without an explicit step is deprecated, write10..1//-1instead
ExUnit
- [ExUnit.Case]
register_test/4is deprecated in favor ofregister_test/6for performance reasons
v1.17.0-rc.1
1. Enhancements
Elixir
- [Duration] Add
Duration.to_iso8601/1andDuration.from_iso8601/1 - [Keyword] Add
Keyword.intersect/2-3to mirror theMapAPI
Mix
- [mix profile.tprof] Add a new profiler, available on Erlang/OTP 27+, which can measure count, time, and heap usage
- [mix test] Generate cover HTML files in parallel
2. Bug fixes
Elixir
- [Kernel] Avoid double tracing events when capturing a function
- [Kernel] Fix a bug where captured arguments would conflict when a capture included a macro that also used captures
3. Soft deprecations
Mix
- [mix profile.cprof] Deprecated in favor of the new
mix profile.tprof - [mix profile.eprof] Deprecated in favor of the new
mix profile.tprof
v1.17.0-rc.0
This release includes type inference of patterns to provide warnings for an initial set of constructs (binaries, maps, and atoms). It also includes a new Duration data type to interact with Calendar types and support for Erlang/OTP 27.
Warnings from gradual set-theoretic types
This release introduces gradual set-theoretic types to infer types from patterns and guards and use them to type check programs, enabling the Elixir compiler to find faults and bugs in codebases without requiring changes to existing software. The underlying principles, theory, and roadmap of our work have been outlined in "The Design Principles of the Elixir Type System" by Giuseppe Castagna, Guillaume Duboc, José Valim.
At the moment, Elixir developers will interact with set-theoretic types only through warnings found by the type system. The current implementation models all data types in the language:
-
binary(),integer(),float(),pid(),port(),reference()- these types are indivisible. This means both1and13get the sameinteger()type. -
atom()- it represents all atoms and it is divisible. For instance, the atom:fooand:hello_worldare also valid (distinct) types. -
map()and structs - maps can be "closed" or "open". Closed maps only allow the specified allows keys, such as%{key: atom(), value: integer()}. Open maps support any other keys in addition to the ones listed and their definition starts with..., such as%{..., key: atom(), value: integer()}. Structs are closed maps with the__struct__key. -
tuple(),list(), andfunction()- currently they are modelled as indivisible types. The next Elixir versions will also introduce fine-grained support to them.
We focused on atoms and maps on this initial release as they are respectively the simplest and the most complex types representations, so we can stress the performance of the type system and quality of error messages. Modelling these types will also provide the most immediate benefits to Elixir developers. Assuming there is a variable named user, holding a %User{} struct with an address field, Elixir v1.17 will emit the following warnings at compile-time:
-
Pattern matching against a map or a struct that does not have the given key, such as
%{adress: ...} = user(noticeaddressvsadress) -
Accessing a key on a map or a struct that does not have the given key, such as
user.adress -
Updating a struct or a map that does not define the given key, such as
%{user | adress: ...} -
Invoking a function on non-modules, such as
user.address() -
Capturing a function on non-modules, such as
&user.address/0 -
Performing structural comparisons with structs, such as
my_date < ~D[2010-04-17] -
Performing structural comparisons between non-overlapping types, such as
integer >= string -
Building and pattern matching on binaries without the relevant specifiers, such as
<<string>>(this warns because by default it expects an integer) -
Attempting to rescue an undefined exception or an exception that is not a struct
-
Accessing a field that is not defined in a rescued exception
These new warnings help Elixir developers find bugs earlier and give more confidence when refactoring code, especially around maps and structs. While some of these warnings were emitted in the past, they were discovered using syntax analysis. The new warnings are more reliable, precise, and with better error messages. Keep in mind that not all maps have statically known keys, and the Elixir typechecker only infers types from patterns at the moment.
Future Elixir versions will infer and type check more constructs, bringing Elixir developers more warnings and quality of life improvements without changes to code. For more details, see our new reference document on gradual set-theoretic types.
The type system was made possible thanks to a partnership between CNRS and Remote. The development work is currently sponsored by Fresha, Starfish*, and Dashbit.
Erlang/OTP support
This release adds support for Erlang/OTP 27 and drops support for Erlang/OTP 24. We recommend Elixir developers to migrate to Erlang/OTP 26 or later, especially on Windows. Support for WERL (a graphical user interface for the Erlang terminal on Windows) will be removed in Elixir v1.18.
Adding Duration and shift/2 functions
Elixir introduces the Duration data type and APIs to shift dates, times, and date times by a given duration, considering different calendars and time zones.
iex> Date.shift(~D[2016-01-31], month: 2)
~D[2016-03-31]Note the operation is called shift (instead of add) since working with durations does not obey properties such as associativity. For instance, adding one month and then one month does not give the same result as adding two months:
iex> ~D[2016-01-31] |> Date.shift(month: 1) |> Date.shift(month: 1)
~D[2016-03-29]Still, durations are essential for building intervals, recurring events, and modelling scheduling complexities found in the world around us. For DateTimes, Elixir will correctly deal with time zone changes (such as Daylight Saving Time), but provisions are also available in case you want to surface conflicts (for example, you shifted to a wall clock that does not exist, because the clock has been moved forward by one hour). See DateTime.shift/2 for examples.
Finally, a new Kernel.to_timeout/1 function has been added, which helps developers normalize durations and integers to a timeout used by Process APIs. For example, to send a message after one hour, one can now write:
Process.send_after(pid, :wake_up, to_timeout(hour: 1))1. Enhancements
Elixir
- [Access] Add
Access.find/1that mirrorsEnum.find/2 - [Code] Support cursor inside fn/rescue/catch/else/after inside
Code.Fragment.container_cursor_to_quoted/2 - [Date] Add
Date.shift/2to shift dates with duration and calendar-specific semantics - [Date] Allow
Dateto accept years outside of-9999..9999range - [DateTime] Add
DateTime.shift/2to shift datetimes with duration and calendar-specific semantics - [Duration] Add a new
Durationdata type - [GenServer] Add
c:GenServer.format_status/1callback - [Kernel] Add
Kernel.get_in/1with safe nil-handling for access and structs - [Kernel] Add
Kernel.is_non_struct_map/1guard - [Kernel] Add
Kernel.to_timeout/1 - [Kernel] Emit warnings for undefined functions from modules defined within the same context as the caller code
- [Kernel] Support integers in uppercase sigils
- [Macro] Add
Macro.Env.define_alias/4,Macro.Env.define_import/4,Macro.Env.define_require/4,Macro.Env.expand_alias/4,Macro.Env.expand_import/5, andMacro.Env.expand_require/6to aid the implementation of language servers and embedded languages - [NaiveDateTime] Add
NaiveDateTime.shift/2to shift naive datetimes with duration and calendar-specific semantics - [Process] Add
Process.set_label/1 - [String] Add
String.byte_slice/3to slice a string to a maximum number of bytes while keeping it UTF-8 encoded - [System] Support
use_stdio: falseinSystem.cmd/3andSystem.shell/2 - [Time] Add
Time.shift/2to shift times with duration and calendar-specific semantics
ExUnit
- [ExUnit] Propagate the test process itself as a caller in
start_supervised - [ExUnit] Include max cases in ExUnit reports
IEx
- [IEx.Helpers] Warns if
recompilewas called and the current working directory changed - [IEx.Helpers] Add
c/0as an alias tocontinue/0 - [IEx.Pry] Add
IEx.Pry.annotate_quoted/3to annotate a quoted expression with pry breakpoints
Logger
- [Logger] Format
:gen_statemreports using Elixir data structures - [Logger] Include process label in logger events
Mix
- [mix deps] Add
:depthoption toMix.SCM.Git, thus supporting shallow clones of Git dependencies - [mix deps] Warn if
:optionalis used in combination with:in_umbrella - [mix deps.get] Do not add optional dependency requirements if its parent dep was skipped
- [mix deps.tree] Add
--umbrella-onlytomix deps.tree - [mix test] Add
mix test --breakpointsthat sets up a breakpoint before each test that will run - [mix test] Add
mix test --repeat-until-failureto rerun tests until a failure occurs - [mix test] Add
mix test --slowest-modulesto print slowest modules based on all of the tests they hold
2. Bug fixes
Elixir
- [bin/elixir.bat] Improve handling of quotes and exclamation marks in flags
- [Code] Address a bug where AST nodes for
(a -> b)were not wrapped as part of the literal encoder - [Kernel] Resolve inconsistencies of how
..and...are handled at the AST level - [Kernel] Fix parsing precedence of ambiguous operators followed by containers
- [Kernel] Do not expand code in
quote bind_quoted: ...twice - [Kernel] Respect
:lineproperty when:fileis given as option toquote - [Kernel] Do not crash on
Macro.escape/2when passing a quote triplet without valid meta - [Module] Return default value in
Module.get_attribute/3for persisted attributes which have not yet been written to
IEx
- [IEx.Helpers] Update the history size whenever history is pruned
Mix
- [mix deps] Fix error message for diverged SCM definition in sibling
3. Soft deprecations (no warnings emitted)
Elixir
- [GenServer] Deprecate
c:GenServer.format_status/2callback to align with Erlang/OTP 25+