简体   繁体   English

伞编译期间未定义的功能警告

[英]Undefined function warnings during umbrella compilation

I have encountered a strange issue within my umbrella application structure. 我在伞形应用程序结构中遇到了一个奇怪的问题。 When I'm compiling whole project after running mix clean command, I'm getting following warning message from application_a: 在运行mix clean命令后编译整个项目时,我收到来自application_a的以下警告消息:

function ApplicationB.ModuleName.function_name/0 is undefined (module 
ApplicationB.ModuleName is not available)
  lib/file_name.ex:13`

The thing is that the module is there, ApplicationB.ModuleName.function_name/0 is defined and it's public. 关键是模块在那里, ApplicationB.ModuleName.function_name/0已定义并且是公共的。 When I'm running the project from umbrella level in the interactive shell, everything works fine, I can call the function manually and it works as expected. 当我在交互式shell中从伞级运行项目时,一切正常,我可以手动调用该函数,并且按预期方式工作。 I've been trying to do the research and as far as I can see the function of ApplicationB should be available for ApplicationA as both are within the same umbrella and there is no need to add them into deps list. 我一直在尝试进行研究,据我所知ApplicationB的功能应该对ApplicationA可用,因为两者都在同一个伞下,不需要将它们添加到deps列表中。 If the function is defined in my /lib folder of application_b, it should be available to the rest of applications. 如果该函数在我的application_b的/ lib文件夹中定义,则其余的应用程序应该可以使用该函数。

Does anyone have an idea how to get rid of the warning, and what is more important - explain it? 有谁知道如何摆脱警告,更重要的是-解释它吗? :) :)

I believe you have macros from A used in B and vice versa. 我相信您在B使用了A中的宏,反之亦然。 Elixir compiler builds the modules in the order, required to expand all macros to real AST. Elixir编译器按顺序构建模块,这是将所有宏扩展为实际AST所必需的。 Within one application, cross-dependencies might even break the build. 在一个应用程序中,交叉依赖甚至可能破坏构建。

But when two applications have cross-dependencies, Elixir compiler makes an assumption that the function might become available after the dependencies are met and everything is built and the error has downgraded to a warning. 但是,当两个应用程序具有交叉依赖关系时,Elixir编译器将假定该函数在满足依赖关系并构建所有内容并将错误降级为警告后可能可用。

To get rid of this warning, if you are absolutely positive there is indeed such a function defined, use Kernel.apply/3 instead of an explicit call. 要消除此警告,如果绝对肯定, 则确实定义了这样的函数,请使用Kernel.apply/3而不是显式调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM