# LDC-E1317 — Free variable in a comprehension ## What it means 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. ## Example ```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))); } ``` ## Fix ```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))); } ``` ## Engine message The engine reports this in its own wording: ```text 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 ``` ## Related - [Strict rules](/constructs/rule-strict/) — binders and what a rule body may use. - [Expressions and quantities](/constructs/expressions-quantities/) — values, units, and their canonical shapes.