docs← Back to article

Markdown for LLMs

LDC-W2152 — Function result type does not fit the destination

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

Download this articlePlain text ↗
# LDC-W2152 — Function result type does not fit the destination

## What it means

A call to a function declared in the same package stands where the
destination declares a type, and the function's declared result type is
known not to fit it: a whole number where text is expected, an entity
where a number is expected, or money in one named currency where another
named currency is expected.

The compiler keeps the kind of a call result unknown, so the destination
type is not checked against the call and the mismatch passes silently. The
warning reads only the function's declared signature, never its body, and
names both the declared result and the destination type.

Nothing is reported when the evidence is incomplete: a function from
another package, two functions with the same name, plain money without a
named currency, or a subtype chain the compiler cannot see in full. A whole
number in a decimal destination is accepted. The warning never fails the
check.

## Example

```law
language "law.core" version "0.2";
package demo.diagnostics version "0.1.0";
namespace "urn:law:demo:diagnostics";

relation named(t: Text) kind institutional;

pure function three() -> Integer = 3;

rule R strict {
    then named(three());
}
```

## Fix

```law
language "law.core" version "0.2";
package demo.diagnostics version "0.1.0";
namespace "urn:law:demo:diagnostics";

relation named(t: Text) kind institutional;

pure function three() -> Text = "three";

rule R strict {
    then named(three());
}
```

## Engine message

The engine reports this in its own wording:

```text
example.law:10:16: warning LDC-W2152: function three declares result Integer, incompatible with slot type Text; the call's inferred kind stays unknown, so the slot type is not checked (§46, §48)
```

## Related

- [Expressions and quantities](/constructs/expressions-quantities/) — value kinds in terms.
- [Vocabulary](/constructs/vocabulary/) — declared types of relation arguments.