Skip to content
docs
Arxo ↗

LDC-E1317 — Free variable in a comprehension

For LLMs5 sections

A comprehension introduces exactly one variable of its own; every other name inside the generator must arrive bound — by a rule binder, by a local binding, or as a declared package symbol. A name with no binder anywhere is free, and silent substitution would build a query that never fires, so the compiler stops at the name.

The repair is to bind the name: add it to the rule binders, or spell the intended bound variable. A generator where every name resolves lowers exactly as written.

Arxo Law
language "law.core" version "0.2";
package demo.diagnostics version "0.1.0";
namespace "urn:law:demo:diagnostics";
entity Tenant;
relation team(t: Tenant) kind empirical;
relation scored(t: Tenant, g: Integer) kind empirical;
relation total(t: Tenant, n: Integer) kind derived;
rule Total strict {
for t: Tenant;
when team(t);
then total(t, sum(collect all g: Integer where scored(m, g)));
}
Arxo Law
language "law.core" version "0.2";
package demo.diagnostics version "0.1.0";
namespace "urn:law:demo:diagnostics";
entity Tenant;
relation team(t: Tenant) kind empirical;
relation scored(t: Tenant, g: Integer) kind empirical;
relation total(t: Tenant, n: Integer) kind derived;
rule Total strict {
for t: Tenant;
when team(t);
then total(t, sum(collect all g: Integer where scored(t, g)));
}

The engine reports this in its own wording:

Output
example.law:12:59: error LDC-E1317: name "m" in a §52.1 comprehension generator is bound by neither a rule binder, nor `let`, nor the comprehension's own variable, and is not declared as a package symbol — it is a free variable (§188 unresolved name). Silent constant substitution would yield a norm that never fires

Documentation for Arxo. Writings — blog.arxo.io.

Anonymous visit counts on stats.arxo.io, no cookies.