【问题标题】:Error when compiling Erlang modules in Windows在 Windows 中编译 Erlang 模块时出错
【发布时间】:2018-06-14 04:01:38
【问题描述】:

我是 Erlang 和 Stack Overflow 编程的初学者,所以我希望这不是一个非常愚蠢的问题。

我在 Windows 10 上从官方网站安装了 Erlang/OTP 20.1。我正在尝试从 erl、werl 或 git bash(从正确的目录)编译一些简单的 Erlang 模块,我收到以下错误:

3> c(useless).
useless.erl: internal error in beam_asm;
crash reason: undef

in function  maps:size/1
 called as maps:size(#{})
in call from beam_dict:atom/2 (beam_dict.erl, line 88)
in call from beam_asm:assemble/5 (beam_asm.erl, line 65)
in call from beam_asm:module/5 (beam_asm.erl, line 62)
in call from compile:beam_asm/2 (compile.erl, line 1454)
in call from compile:'-internal_comp/5-anonymous-1-'/3 (compile.erl, line 342)
in call from compile:fold_comp/4 (compile.erl, line 369)
in call from compile:internal_comp/5 (compile.erl, line 353)

你认为问题是什么?无论保存在哪里,每个模块都会出现完全相同的错误。有趣的是,我昨天可以毫无问题地编译和运行这些模块,但我昨天遇到了同样的问题!

非常感谢!

伯纳特

【问题讨论】:

  • 你能发布你的源代码吗?
  • 你的意思是我试图运行的模块的代码?
  • 是的,您提到每个模块都会出现此错误。你能发布你能想出的最简单模块的代码,看看这个错误是否再次发生? (例如,一个模块只包含一个只返回其参数的函数。)
  • -module(tut1). -export([fac/1]). fac(1) -> 1; fac(N) -> N* fac(N-1).

标签: compiler-errors erlang beam


【解决方案1】:

您是否创建了一个名为“地图”的模块?在这种情况下,问题在于您已经用没有此类功能的标准地图模块(包含 size/1 函数)覆盖,因此是“undef”。

【讨论】:

  • 是的,我想我在某个时候这样做是为了练习一些教程。但是,即使在杀死所有作业、重新启动编译器并重新安装 Erlang 之后,所有模块都会出现相同的错误。这可能与这个问题有什么关系?
  • 如果您创建的 maps.beam 文件仍然存在于您的当前目录(或您的 erlang 代码路径中的任何其他位置)中,它将在编译器尝试时被加载,而不是标准库中的那个调用 maps:size/1.
  • 是的,你是对的,这正是问题所在!标准地图模块包含什么?
  • 地图的实用功能,用于执行#{...} 语法未涵盖的操作:erlang.org/doc/man/maps.html
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-04-08
  • 1970-01-01
  • 2013-06-20
  • 2015-12-20
  • 1970-01-01
  • 2010-11-19
  • 2020-03-19
相关资源
最近更新 更多