简体   繁体   English

是什么导致Mercury中的函子“ field_name / 1”的参数类型错误?

[英]What causes type error in argument(s) of functor `field_name/1' in Mercury?

When I compile my source , I get the following error: type error in argument(s) of functor `source/1' 编译源代码时,出现以下错误:在函子`source / 1'的参数中键入error

The compiler correctly determines the types of the arguments, but keeps trying to use a field from a different record. 编译器可以正确确定参数的类型,但是会继续尝试使用其他记录中的字段。

Whats wrong? 怎么了?

The problem is a missing ':- include_module' for the data type being used. 问题是所使用的数据类型缺少':-include_module'。 The compiler knows what the type is, even if you don't have the module specified. 即使您没有指定模块,编译器也知道类型是什么。

I found the answer by using the more verbose syntax: 我通过使用更详细的语法找到了答案:

my_functor(Val1, Val2, Val3) = Variable my_functor(Val1,Val2,Val3)=变量

Where the compiler clearly told me that my_functor wasn't defined. 编译器清楚地告诉我my_functor没有定义。 In this particular instance, the "source" field was named in two different structures in two different modules, one of which was imported, making the error message somewhat more confusing. 在此特定实例中,“源”字段在两个不同模块中的两个不同结构中被命名,其中一个被导入,从而使错误消息更加混乱。

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

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