The strict reading of the condition of a boxed expression (DMN 1.6, 10.2.1.8 to 10.2.1.10; D-212).
The if of a boxed conditional, the brackets of a boxed filter and the satisfies of a boxed some or every MUST resolve to
a boolean. Written as text, FEEL takes a condition that is not true as false (Table 50: if "abc" then 1 else 2 is 2), and a
layer above feel that builds the node from a box marks it boxed: true in its meta, which says that a condition that is a
value other than a boolean is null and an error, for the whole node, as the DMN TCK has it (1150 #003, 1151 #004 and #005,
1153 #006).
null is not this case: it is the result of a comparison with a missing value, and it is taken as false (the else branch, the
element is dropped), as it is in the text. Only a value that is neither a boolean nor null is a violation. A number in the
brackets of a filter is an index, as it is in the text, and is decided before this module is asked.
Both backends ask this module, so they report the same.
Summary
Functions
Whether the value of a condition is allowed: a boolean, or null.
The diagnostic of a condition that is not a boolean: a :type_mismatch, with the part of the box in its details.
The result of a boxed node whose condition is not a boolean: null and the error, at the span of the node.
Types
Functions
@spec allowed?(Feel.Value.t()) :: boolean()
Whether the value of a condition is allowed: a boolean, or null.
iex> Feel.Runtime.Boxed.allowed?(true)
true
iex> Feel.Runtime.Boxed.allowed?(nil)
true
iex> Feel.Runtime.Boxed.allowed?("abc")
false
@spec diagnostic(Feel.Value.t(), part()) :: Feel.Diagnostic.t()
The diagnostic of a condition that is not a boolean: a :type_mismatch, with the part of the box in its details.
iex> diagnostic = Feel.Runtime.Boxed.diagnostic("abc", :if)
iex> {diagnostic.code, diagnostic.severity, diagnostic.details}
{:type_mismatch, :error, %{boxed: :if}}
@spec violation(Feel.Runtime.Env.t(), Feel.Value.t(), part(), Feel.Diagnostic.span()) :: {Feel.Value.t(), Feel.Runtime.Env.t()}
The result of a boxed node whose condition is not a boolean: null and the error, at the span of the node.
iex> env = Feel.Runtime.Env.new()
iex> {nil, env} = Feel.Runtime.Boxed.violation(env, "abc", :if, {0, 3})
iex> Enum.map(Feel.Runtime.Env.diagnostics(env), & &1.code)
[:type_mismatch]