tallakt / codepagex

Elixir string encoding conversion - like iconv but pure Elixir
Other
110 stars 20 forks source link

Do not use Keyword.keys when data isn't a keyword list #22

Closed rodrigues closed 4 years ago

rodrigues commented 4 years ago

The key isn't an atom, but a binary, that doesn't work well in Elixir 1.11.0-dev.

# Interactive Elixir (1.10.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Keyword.keys([{"a", 1}])
["a"]
# Interactive Elixir (1.11.0-dev) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Keyword.keys([{"a", 1}])
** (ArgumentError) expected a keyword list, but an entry in the list is not a two-element tuple with an atom as its first element, got: {"a", 1}
    (elixir 1.11.0-dev) lib/keyword.ex:457: Keyword.keys/1

I've tried to compile my app in Elixir 1.11.0-dev (still not released) and couldn't compile this codepagex dependency.

rodrigues commented 4 years ago

hey @tallakt , today elixir 1.11.0-rc was released, and this is still an issue:

/codepagex.ex:69: Codepagex

== Compilation error in file lib/codepagex.ex ==
** (ArgumentError) expected a keyword list, but an entry in the list is not a two-element tuple with an atom as its first element, got: {"ISO8859/8859-1", "/Users/rodrigues/code/priv/vic/va/deps/codepagex/lib/codepagex/../../unicode/ISO8859/8859-1.TXT"}
    (elixir 1.11.0-rc.0) lib/keyword.ex:475: Keyword.keys/1
    lib/codepagex/mappings.ex:179: Codepagex.Mappings.encoding_list/1
    lib/codepagex/mappings.ex:135: anonymous fn/1 in Codepagex.Mappings.aliases/1
    (elixir 1.11.0-rc.0) lib/enum.ex:924: anonymous fn/3 in Enum.filter/2
    (stdlib 3.12.1) maps.erl:232: :maps.fold_1/3
    (elixir 1.11.0-rc.0) lib/enum.ex:2201: Enum.filter/2
    lib/codepagex/mappings.ex:134: Codepagex.Mappings.aliases/1
    lib/codepagex.ex:294: (module)
could not compile dependency :codepagex, "mix compile" failed. You can recompile this dependency with "mix deps.compile codepagex", update it with "mix deps.update codepagex" or clean it with "mix deps.clean codepagex"

could we merge and release this pls? 😁💜

tallakt commented 4 years ago

I will have this in v 0.1.6