hissssst / pathex

Fastest tool to access data in Elixir
BSD 2-Clause "Simplified" License
337 stars 17 forks source link

Error when using tuple with variable in path creation #16

Closed ltd closed 2 years ago

ltd commented 2 years ago

Great Library!

using a variable inside a tuple key fails, also I think the error message about the pin operator is now invalid.

iex > val = "xxx"
iex > path  :x / {:foo, val}
** (CompileError) cannot use variable val as map key inside a pattern. Map keys in patterns can only be literals (such as atoms, strings, tuples, and the like) or an existing variable matched with the pin operator (such as ^some_var)

but wrapping the tuple in a variable works just fine

iex > key = {:foo, val}
{:foo, "xxx"}
iex > path :x / key
#Function<43.65746770/2 in :erl_eval.expr/5>