Error Code: SHADOWED_VARIABLE
This guide explains why a shadowed variable error may occur and describes how to fix it.
In Rel, all variables have to be explicitly introduced to clarify their scope.
Moreover, they are introduced by bindings.
For instance, a local scalar variable x
shadows relation definitions, schema, and natives with name x
.
Consider the following example that returns a shadowed variable error:
def names = {"Patrick"; "Joe"}
def dbl_names(n, n) = names(n)

The query above defines the relation dbl_names
with the purpose of doubling the elements of the tuples in the relation names
.
However, it also uses the same variable name, i.e., n
, in the binding for the relation dbl_names
.
This returns the shadowed variable error.
To fix this, you have to use a different name for every variable in a certain enclosing scope. For example:
// read query
def names = {"Patrick"; "Joe"}
def dbl_names(x, y) = {names(x) and names(y)}
def output = dbl_names