-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Strange error reporting when importing module #4120
Comments
Thank you for the report! When you define: defmodule My.MyModule do
defmodule My.CustomModule do
end
defmacro __using__(_) do
quote do
import My.MyModule
end
end
end In order for |
Thanks for the quick reply. |
It says My.MyModule.My.Module because your code now has an alias where |
Maybe we could improve defmodule Foo do
defmodule Bar do
end
end will create an alias to defmodule Foo do
defmodule Bar.Baz do
end
end will create an alias to |
Thanks @josevalim for the explanation. Doubt cleared. I think I ignored the fact that aliase are lexically scoped after reading your first reply. Also i agree with @tuvistavie that improving documentation might help beginner like me. |
Ohh there is an example here http://elixir-lang.org/getting-started/alias-require-and-import.html for explaining alias. Sorry for the trouble. I also updated my answer in SO http://stackoverflow.com/questions/34471538/unable-to-understand-import-via-using-macro-elixir-phoenix/. Thanks @josevalim |
I have made a repo with minimal code to generate a strange error. Error seems strange to me. It is generated when we write code as following.
Below is the repo link with minimal code: https://github.com/rohanpujaris/strangerror_elixir
I know that the thing that I tried is little weird and chances of others trying it is very rare. But it took me nearly 3hr to figure out what was the issue. If I haven't looked into error reported by the elixir, I would have solved it earlier. I feel the error is highly misleading.
When we compile code from above repo it will return below error.
I was trying to use behaviours and I declared module inside another and after writing few lines of code I compiled the project and got above error. I have also raised question in stackoverflow http://stackoverflow.com/questions/34471538/unable-to-understand-import-via-using-macro-elixir-phoenix/ . But after finding out the reason, I feel like its better to report it here as an issue.
Also there is other thing which i felt was strange. When I transformed above code as below the error was gone.
The text was updated successfully, but these errors were encountered: