Skip to content

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

@pminten

Description

@pminten
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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions