Markdown for LLMs
LDC-W2150 — Conditional branches of different kinds in a typed slot
The source Markdown for this article. Copy it into your assistant or download it as a text file.
# LDC-W2150 — Conditional branches of different kinds in a typed slot
## What it means
A conditional expression stands where the destination declares a type: a
relation argument, a typed local, a constant, a function result or a
function argument. Its two branches have different known kinds, for
example a whole number in one branch and text in the other.
A value has exactly one kind, and the compiler does not unify branches of
different kinds. The conditional therefore gets no kind of its own, and the
destination type is not checked against it: a branch the slot would reject
on its own passes silently. The warning names both branches.
Branches that the slot already accepts stay silent: a whole number and a
decimal in a decimal slot is fine. If either branch kind is unknown to the
compiler, nothing is reported. 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 score(n: Integer) kind institutional;
rule R strict {
then score(if true then 1 else "one");
}
```
## Fix
```law
language "law.core" version "0.2";
package demo.diagnostics version "0.1.0";
namespace "urn:law:demo:diagnostics";
relation score(n: Integer) kind institutional;
rule R strict {
then score(if true then 1 else 2);
}
```
## Engine message
The engine reports this in its own wording:
```text
example.law:8:16: warning LDC-W2150: if branches have different known kinds Integer and Text in a slot of type Integer; the branch kinds are not unified, so the slot type is not checked (§56, §48)
```
## Related
- [Expressions and quantities](/constructs/expressions-quantities/) — conditional expressions and value kinds.
- [LDC-E2104](/diagnostics/LDC-E2104/) — the error a single branch of the wrong kind gets on its own.