Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function_exported? is not as reliable as __info__(:functions) #6

Open
SkipMike opened this issue Oct 3, 2018 · 1 comment
Open

Comments

@SkipMike
Copy link

SkipMike commented Oct 3, 2018

I have some ecto embedded schemas that seems just like structs in all cases except when Maptu calls function_exported?(DB.SQL.Schema.Cart.Loyalty, :__struct__, 0) which returns false. After I instantiate a struct with %DB.SQL.Schema.Cart.Loyalty{} then function_exported?(DB.SQL.Schema.Cart.Loyalty, :__struct__, 0) returns true. However, DB.SQL.Schema.Cart.Loyalty.module_info(:exports) always returns an up to date list of functions.

https://github.com/elixir-lang/elixir/blob/v1.7.3/lib/elixir/lib/kernel.ex#L3245 After reading the documentation for function_exported? It's clear that it doesn't load the code, if it's not already loaded. This makes sense, because it's only happening in my test environment. In any case, I think it would be easier to use Maptu if we can make the change to use module_info or __info__ instead of function_exported?. I'm happy to make a PR, if that would help.

@SkipMike
Copy link
Author

SkipMike commented Oct 5, 2018

@lexmag Is there something I can do to push this forward? I'd love to get this fix into production.

@SkipMike SkipMike mentioned this issue Oct 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant