whatyouhide / short_maps

⚠️Retired⚠️ library that provided a ~m sigil for ES6-like map destructuring in Elixir.
https://andrealeopardi.com/posts/a-story-of-regret-and-retiring-a-library-from-hex/
77 stars 5 forks source link

Unable to refer to struct with same name as module #7

Closed Havvy closed 8 years ago

Havvy commented 8 years ago

E.g. this doesn't work.

defmodule X do
  import ShortMaps

  defstruct [a: nil]

  def foobar(~m{%X a}) do
    a
  end
end
whatyouhide commented 8 years ago

@Havvy the implementation of structs is broken because it makes bad assumptions :( I'll try to fix it when I got some time :+1:

/cc @jwarlander

jwarlander commented 8 years ago

The proposed changes should make the struct name resolve to the proper module within the context of the caller :) For convenience (because I use the syntax myself sometimes when working within the module of the struct), I made sure it works as ~m{%__MODULE__ a} as well.