elixir icon indicating copy to clipboard operation
elixir copied to clipboard

False recognition of block expressions (not allowed with `&` capture)

Open pminten opened this issue 13 years ago • 0 comments

Enum.drop_while(["alfred", "berta", "claire"], &(!String.starts_with?(&1, "ber")))
** (SyntaxError) iex:2: invalid args for &, block expressions are not allowed, got: !String.starts_with?(&1, "alf")
    src/elixir_translator.erl:596: :elixir_translator.translate_arg/2
    lists.erl:1339: :lists.mapfoldl/3
    lists.erl:1340: :lists.mapfoldl/3
    src/elixir_translator.erl:603: :elixir_translator.translate_args/2
    src/elixir_translator.erl:632: :elixir_translator.translate_apply/7
    lists.erl:1339: :lists.mapfoldl/3
    src/elixir.erl:134: :elixir.eval_forms/3

But

Enum.drop_while(["alfred", "berta", "claire"], &!String.starts_with?(&1, "alf"))
["berta", "claire"]

It seems the translator thinks an unary expression inside parentheses is a block. While obviously the form without parentheses is nicer this does seem to be a bug.

pminten avatar Sep 10 '13 09:09 pminten