To expand on that, that's because the Elixir compiler compiles everything
in parallel, so at compilation time, we don't know what is defined yet.

Furthermore, this is sometimes desired behaviour. For example, when it
comes to optional dependencies. Ecto, for instance, can work with both
Jason and Poison, so it calls both, but if a dev only has Jason as a
dependency, Ecto should still compile.

*José Valim*
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D


On Fri, Mar 1, 2019 at 7:12 AM Alexei Sholik <[email protected]> wrote:

> Mix does warn about it when you try to call a function from a non-existent
> module:
>
> $ mix compile
> Compiling 1 file (.ex)
> warning: function This.Module.Does.Not.Exist.foo/0 is undefined (module
> This.Module.Does.Not.Exist is not available)
>
> It does so because `mix xref` runs automatically on each compilation. The
> base Elixir compiler doesn't perform such checks.
>
> On Fri, Mar 1, 2019 at 4:08 PM Jan Ziniewicz <[email protected]>
> wrote:
>
>>
>> Hi everyone,
>>
>> Please take a look at this line of code:
>>
>> alias This.Module.Does.Not.Exist
>>
>> In my opinion compiler should emit an error or at least warning when
>> trying to alias a non existent module? However, this line is perfectly
>> valid  piece of code.
>> Asking just out of curiosity, is this a bug or a feature?
>>
>> Best, Jan
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "elixir-lang-core" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/elixir-lang-core/3bc43a69-ad37-4323-be65-f7ddac4aaead%40googlegroups.com
>> <https://groups.google.com/d/msgid/elixir-lang-core/3bc43a69-ad37-4323-be65-f7ddac4aaead%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-core/CAAPY6ePFexxHpxBGmR4Bjxa_xQgXAibTsEnAU97S%2BrF1udPPkQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/elixir-lang-core/CAAPY6ePFexxHpxBGmR4Bjxa_xQgXAibTsEnAU97S%2BrF1udPPkQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4K-r8Of4LO71SiXbj-FYuV_DdTy2r52PXHwEuncgD-tvg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to