Skip to content
HELP
ERROR MESSAGES
UNBOUND VARIABLE

Error Code: UNBOUND_VARIABLE

This guide explains why an unbound variable error may occur and describes how to fix it.

A variable in Rel is considered to be not bound or unbound if there’s an unknown source of values for it. The difference between ungrounded and unbound variables refers to how the system detetcs the error, i.e., the system uses unbound errors when the problem can be detected by applying purely syntactic criteria. In this sense, unbound implies ungrounded. The unbound errors come from the front-end compiler, whereas the ungrounded ones come from the query optimizer.

The following example returns an unbound variable error:

def r(x, y) = {x = 1}
Error example from the RAI Console

This example defines the relation r and declares the value for the variable x. However, it doesn’t declare the value for the variable y, and therefore the system can’t evaluate it. Here’s how to write the example correctly:

// read query
 
def r(x, y) = {x = 1 and y = 2}
def output = r

See Grounded Variables in the Rel Language Reference manual and Grounded and Ungrounded Variables in the Rel Primer: Advanced Syntax guide for more details.

Was this doc helpful?