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

48 Views Asked by At

When I compile my source , I get the following error: type error in argument(s) of functor `source/1'

The compiler correctly determines the types of the arguments, but keeps trying to use a field from a different record.

Whats wrong?

1

There are 1 best solutions below

0
On

The problem is a missing ':- include_module' for the data type being used. 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

Where the compiler clearly told me that my_functor wasn't defined. 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.