Elixir

Elixir

Elixir Core Team

Elixir v1.20.0-rc.0 (and rc.1) released: type inference of all constructs

Today we celebrate 15 years since Elixir’s first commit! To mark the occasion, we are glad to announce the first release candidate for Elixir v1.20, which performs type inference of all language constructs, with increasing precision.

In this blog post, we will break down exactly what this means, and what to expect in the short and medium term of the language evolution (roughly the next 15 months).

Read the full announcement here:

Release notes:

TL;DR: this release adds type inference of all constructs. At the moment, we expect false positives (warnings that should not be emited), please let us know if you run into those. Also, please let us know about performance. If Elixir v1.20 compiles slower than v1.19, then ping us too. `mix compile –force –profile time` is a good tool to measure it (paticularly the times reported at the end).

Most Liked

josevalim

josevalim

Creator of Elixir

1. Bug fixes

Elixir

  • [Kernel] Improve the performance of the type system when working with large unions of open maps
  • [Kernel] Do not crash on map types with struct keys when performing type operations
  • [Kernel] Mark the outcome of bitstring types as dynamic
  • [Kernel] <<expr::bitstring>> will have type binary instead of bitstring if expr is a binary
  • [Kernel] Do not crash on conditional variables when calling a function on a module which is represented by a variable

I am keeping it all in the same thread as we only had bug fixes.

AstonJ

AstonJ

:041: Thanks for another awesome release and congratulations on 15 amazing years!! :041:

12
Post #6
Awlexus

Awlexus

I just finished upgrading a rather big project to 1.19.5 and resolving all warnings. After setting the elixir version to 1.20.0-rc.1 and running mix.compile the compiler revealed many new warnings

  • Found a lot of unused required modules. Mostly Logger and Ecto.Query (TIL you don’t need to require the Logger to make use of Logger.metadata)

  • Possible false positive or future deprecation? This warning was emitted, but pinning the variable here has no effect aside from removing the warning

    warning: the variable "chunk_size" is accessed inside size(...) of a bitstring but it was defined outside of the match. You must precede it with the pin operator
        │
    118 │     <<chunk::binary-size(chunk_size), rest::binary>> = binary
    
  • It found a couple of interesting, unused function clauses, similar to the cases below. In this particular case it was fine, but there are some cases where I cannot figure out the reason. Still a great addition to the compiler :+1:

    current = Enum.at(search_results, current_index)
    highlight_term(current.sentence_text, current)}
    
         warning: this clause of defp highlight_term/2 is never used
         │
     194 │   defp highlight_term(text, nil), do: text
    
  • In this particular case it didn’t complain about the fact that we (accidentally) assumed that uri.query is a map, but we’re trying to pass a map to URI.decode_query. Still a great find :+1:

         warning: incompatible types given to URI.decode_query/1:
    
             URI.decode_query(query)
    
         given types:
    
             dynamic(map())
    
         but expected one of:
    
             binary()
    
         where "query" was given the type:
    
             # type: dynamic(map())
             # from: my_code.ex:187:33
             is_map(query)
    
         typing violation found at:
         │
     188 │            %{"latency" => latency_raw} <- URI.decode_query(query),
    
        uri = URI.parse(url)
    
        latency =
          with %{query: query} when is_map(query) <- uri,
               %{"latency" => latency_raw} <- URI.decode_query(query),
               {latency, ""} <- Integer.parse(latency_raw) do
    
    

I’ve also measured the performance of the compilation of this project a bit. ~190 dependencies and +800 files. Overall very happy with the results and MIX_OS_DEPS_COMPILE_PARTITION_COUNT is a blessing for sure
deps = mix deps.compile
project = mix compile

elixir_version stage partitions seconds
1.18.4-otp-28 deps unset 73.95
1.18.4-otp-28 project 11.57
1.19.3-otp-28 deps unset 68.80
1.19.3-otp-28 deps 2 41.78
1.19.3-otp-28 deps 4 31.60
1.19.3-otp-28 project 13.65
1.19.5-otp-28 deps unset 68.00
1.19.5-otp-28 deps 2 41.60
1.19.5-otp-28 deps 4 31.72
1.19.5-otp-28 project 12.88
1.20.0-rc.1-otp-28 deps unset 69.54
1.20.0-rc.1-otp-28 deps 2 41.56
1.20.0-rc.1-otp-28 deps 4 32.22
1.20.0-rc.1-otp-28 project 13.25

Where Next?

Popular in News Top

Elixir
Release: Release v1.9.0 · elixir-lang/elixir · GitHub Releases The main feature in Elixir v1.9 is the addition of releases. A release is...
New
josevalim
Elixir v1.5.0-rc.2 has been released. This is the third release candidate for the upcoming Elixir v1.5. It includes bug fixes, enhanceme...
New
Elixir
Release: Release v1.10.4 · elixir-lang/elixir · GitHub 1. Bug fixes Elixir [Kernel] Fix a bug where custom types were printed as built-...
New
Elixir
1. Enhancements Elixir [Regex] Raise error message when regexes are used as default values in struct fields for compatibility with Erlan...
New
josevalim
Release: https://github.com/elixir-lang/elixir/releases/tag/v1.13.3 1. Enhancements Mix [mix format] Supply file and line to formatter ...
New
josevalim
Hello everyone, We have released Elixir v1.3.3. This release has some compiler- and dialyzer-related improvements as well as some enhanc...
New
Elixir
1. Enhancements Elixir [Protocol] Optimize protocol consolidation to no longer load structs 2. Bug fixes Elixir [Kernel] Fix unnecessa...
New
New
Elixir
1. Bug fixes Elixir [Code] Fix Code.quoted_to_algebra/2 for operator with :do key as operand [Kernel.ParallelCompiler] Do not crash para...
New
josevalim
Hi everyone, We have just released v1.7.0-rc.0. The CHANGELOG and precompiled files are here: Release v1.7.0-rc.0 · elixir-lang/elixir ...
New

Other popular topics Top

Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 43657 311
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New

We're in Beta

About us Mission Statement