Markdown for LLMs
LDC-Q2005 — The expression names a variable the query never bound
The source Markdown for this article. Copy it into your assistant or download it as a text file.
# LDC-Q2005 — The expression names a variable the query never bound
## What it means
Inside a filter or a return list, every name must come from somewhere: a
source introduced at the head of the query. A name with no source is not
an empty value and not a typo the engine will guess past — the expression
cannot be evaluated for any row, so the query stops at the first row that
reaches it.
Bind the name in a source, or replace it with the source variable the
expression was meant to read.
## Example
Both queries below run against this package:
```law
language "law.core" version "0.2";
package demo.diagnostics version "0.1.0";
namespace "urn:law:demo:diagnostics";
entity Applicant;
relation resident(a: Applicant) kind institutional;
relation permit_eligible(a: Applicant) kind institutional;
rule PermitEligibility strict {
for a: Applicant;
when resident(a);
then permit_eligible(a);
}
```
The filter reads a name no source introduces:
```lawql
from r in rules where zzz == 1 select r
```
## Fix
```lawql
from r in rules select r
```
## Engine message
The engine reports this in its own wording:
```text
LDC-Q2005: variable 'zzz' is not bound.
```
## Related
- [Questions to the engine](/constructs/queries/) — how sources bind names.
- [LDC-Q2007](/diagnostics/LDC-Q2007/) — when the name exists but the field does not.