Elixir: Cryptic error message when using reserved keyword in pattern match

Created on 1 Nov 2019  路  1Comment  路  Source: elixir-lang/elixir

Environment

  • Elixir & Erlang/OTP versions (elixir --version): Elixir 1.9.1 (compiled with Erlang/OTP 21)
  • Operating system: Ubuntu 18.04

Current behavior

iex(1)> %{after: a} = %{after: 5}
%{after: 5}
iex(2)> %{after: after} = %{after: 5}
** (SyntaxError) iex:2: syntax error before: 'after'

Expected behavior

An error message saying that 'after' is a reserved keyword.

Elixir (compiler) Chore Intermediate

Most helpful comment

Good call. We can explicitly check for keywords in syntax error before and add a special note. Thanks for the report!

>All comments

Good call. We can explicitly check for keywords in syntax error before and add a special note. Thanks for the report!

Was this page helpful?
0 / 5 - 0 ratings