Elixir: Weird error message when I pass true instead of a do_block

Created on 9 Feb 2018  路  2Comments  路  Source: elixir-lang/elixir

When I write one-liner definitions, and forget to write do:, like so:

iex(1)> defmodule Test do
...(1)> def foo(), true
...(1)> end

the compiler will result in:

** (CompileError) iex:2: invalid arguments for "try"
    iex:2: (module)

Which is a bit confusing. Maybe there could be a better error message.

Elixir Bug Intermediate

Most helpful comment

I will push a fix soon. We raise for missing :do in some cases but not in others, I will make sure we raise it consistently.

All 2 comments

Thanks, I have verified this on master. Please don't forget to include the Elixir version in upcoming reports. :)

I will push a fix soon. We raise for missing :do in some cases but not in others, I will make sure we raise it consistently.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chulkilee picture chulkilee  路  3Comments

ckampfe picture ckampfe  路  3Comments

Paddy3118 picture Paddy3118  路  3Comments

LucianaMarques picture LucianaMarques  路  3Comments

josevalim picture josevalim  路  3Comments