witchcrafters / witchcraft

Monads and other dark magic for Elixir
https://witchcrafters.github.io
MIT License
1.2k stars 58 forks source link

Fix `__using__` for `override_kernel` and `except` #83

Closed jechol closed 3 years ago

jechol commented 4 years ago

For example,

use Witchcraft, override_kernel: false, except: [>=: 2]

would fail to compile because

  1. override_kernel is passed into opts in import unquote(__MODULE__), unquote(opts) that renders wrong argument.

  2. except: [>=2]is passed to Ord.__using__ and its [>=:2, ...] ++ except makes duplicated entry in new_opts in import unquote(__MODULE__), except: unquote(new_opts) which causes compile error.

This PR fixes above bugs.

jechol commented 3 years ago

@icidasset Could you review this?

florius0 commented 3 years ago

It fixes #93

florius0 commented 3 years ago

Doesn't this leave out all other import options, though? For example, :only?

Also, any thoughts on extracting this common functionality inside the using out into a .Internal module? May be premature optimization, but means we don't have to trace down all of these spots in the future.

I've moved it to Witchcraft.Internal module. Should I open a new PR?

jechol commented 3 years ago

@florius0 I think we need to merge this first. Thanks for your advice.