Apparently, openCypher's freshening of variables does not extend to
scoped expressions. We can fix this by manually "freshening" the
variables in the expression subscopes.
The better solution would be to extend the scoping information
maintained by the compiler to include a stack of scopes (when you enter
a new scope you push and when you exit you pop). Unfortunately, that's
not too helpful in Quine's case since the runtime still needs distinct
column names (since it uses QueryContext ~ Map[Symbol, Value] instead
of QueryContext ~ Vector[Value]). If the runtime representation of
query contexts changed, the fix to this problem would be more in line
with the usual compiler approach to scoping.
Apparently, openCypher's freshening of variables does not extend to scoped expressions. We can fix this by manually "freshening" the variables in the expression subscopes.
The better solution would be to extend the scoping information maintained by the compiler to include a stack of scopes (when you enter a new scope you push and when you exit you pop). Unfortunately, that's not too helpful in Quine's case since the runtime still needs distinct column names (since it uses
QueryContext ~ Map[Symbol, Value]
instead ofQueryContext ~ Vector[Value]
). If the runtime representation of query contexts changed, the fix to this problem would be more in line with the usual compiler approach to scoping.