docs← Back to article

Markdown for LLMs

LDC-E1116 — Undeclared cross-file reference

The source Markdown for this article. Copy it into your assistant or download it as a text file.

Download this articlePlain text ↗
# LDC-E1116 — Undeclared cross-file reference

## What it means

A package can span several files, and in the explicit authoring mode
every file declares which of the other files' names it uses. The
declaration lives in a `use self` block at the top of the file. When a
rule reaches for a name declared in another file without listing it
there, the compiler stops at the first use: the reference is real, but
the declaration is missing.

The repair is to list the missing name in the file's `use self` block.
The block names authoring declarations — entities, relations, rules —
one per file that uses them. Files that need nothing declare nothing.

## Example

```run
{"argv": ["check", "$ROOT"], "files": {"law.toml": "[package]\nname = \"demo.diagnostics\"\nversion = \"0.1.0\"\nlanguage = \"0.2\"\nnamespace = \"urn:law:demo:diagnostics\"\n\n[authoring]\nlocal_imports = \"explicit\"\n", "a.law": "language \"law.core\" version \"0.2\";\npackage demo.diagnostics version \"0.1.0\";\nnamespace \"urn:law:demo:diagnostics\";\n\nentity Person;\nrelation adult(p: Person) kind institutional;\nrelation senior(p: Person) kind institutional;\n", "b.law": "language \"law.core\" version \"0.2\";\npackage demo.diagnostics version \"0.1.0\";\nnamespace \"urn:law:demo:diagnostics\";\n\nuse self::{ Person, senior };\n\nrule Senior(p: Person) defeasible {\n    when adult(p);\n    then senior(p);\n}\n"}, "expect": "LDC-E1116"}
```

## Fix

```run
{"argv": ["check", "$ROOT"], "files": {"law.toml": "[package]\nname = \"demo.diagnostics\"\nversion = \"0.1.0\"\nlanguage = \"0.2\"\nnamespace = \"urn:law:demo:diagnostics\"\n\n[authoring]\nlocal_imports = \"explicit\"\n", "a.law": "language \"law.core\" version \"0.2\";\npackage demo.diagnostics version \"0.1.0\";\nnamespace \"urn:law:demo:diagnostics\";\n\nentity Person;\nrelation adult(p: Person) kind institutional;\nrelation senior(p: Person) kind institutional;\n", "b.law": "language \"law.core\" version \"0.2\";\npackage demo.diagnostics version \"0.1.0\";\nnamespace \"urn:law:demo:diagnostics\";\n\nuse self::{ Person, senior, adult };\n\nrule Senior(p: Person) defeasible {\n    when adult(p);\n    then senior(p);\n}\n"}, "expect": null}
```

## Engine message

The engine reports this in its own wording:

```text
$ROOT/b.law:8:10: error LDC-E1116: `adult` is declared in file $ROOT/a.law and not declared in the `use self` of file $ROOT/b.law: in a package with `local_imports = "explicit"` a reference to another file's declaration is declared (§23.2)
```

## Related

- [LDC-E1109](/diagnostics/LDC-E1109/) — the manifest that marks the package root and its authoring mode.
- [Defeasible rules and unless](/constructs/rule-defeasible-unless/) — the rule shape in the example.