Skip to content
  • HELP
  • ERROR MESSAGES
  • UNDEFINED

Error code: UNDEFINED

This guide explains why you may experience an undefined error and how to solve it.

In Rel, a variable is undefined if there is no lexically enclosing declaration. Undefined errors occur most commonly when referring to a relation that has not yet been defined. Particularly, attention has to be paid when referring to relations within modules.

Consider the following example that returns an error:

def zoes_friends = friends["Zoe"] 
Error example from the RAI Console

In the query above, you want to know Zoe’s friends by defining zoes_friends. However, the relation friends has not been previously defined.

A correct example could be:

// query
 
def friends = {("Mike", "Anna"); ("Zoe", "Jenn")}
def zoes_friends = friends["Zoe"]
def output = zoes_friends

This returns Zoe’s friends list.

It may be that you have already defined the friends relation but the compiler is not able to find it. For instance, suppose you define the relation within a module:

module friends_mod
    def friends = {("Mike", "Anna"); ("Zoe", "Jenn")}
end

If you then query zoes_friends as in the first example, the error is still returned. Rel modules can be thought of as nested relations. In the example above, the relation friends is nested inside friends_mod and available as friends_mod[:friends], equivalent to friends_mod:friends.

Therefore, a valid definition of zoes_friends could be:

def zoes_friends = friends_mod:friends["Zoe"]

Similarly, it may happen that while installing some logic as a model, you refer to relations that are yet to be defined, with the plan to define them later in a different model or query. This returns an undefined error from the model installation:

Error example from the RAI Console

In this case, this error may be ignored as long as you define the undefined relation later. Refer to the Working With Models guide to learn more about how to install models using the RAI Console.

Was this doc helpful?