Home / Docs / Diagnostics

U4001: Flow to a lower label

Release v0.4.0

Data flows to a lower label. The message names the declared type and the value's type with their labels.

Why Una rejects it

A label says who may observe a value, and data never flows to a lower label (spec/07 §3): a value flows into a parameter, a field, an annotated let, a policy's from type or a function's result only when each position of its type is labeled below the declared label there.

Labels follow data:

In a generic body, a value decided by comparing values of a type parameter T carries label(T*), every label of T's type argument, which is not below label(T): it cannot flow into an annotation, a field or a function value's parameter of type T, as in [if a == b then p else q].map(each: k).

In edition 0.4, an http grant of run grants with limits needs every Http request timed by internal data at most, since HttpError.RateLimited reveals when each request was made (ADR 0117 IF4, spec/27 §9): a request in a function that also works on a secret parameter is U4001 at the request.

A limiter of std.limit the same (ADR 0117 IF5, spec/27 §10): whether acquire finds a token depends on the timing of the statement its with scopes over, so that statement must be timed by internal data at most; U4001 at the binding otherwise.

In edition 0.4, the host hands the state of a drive module from init to step, from init and step to on_stop, and that hand-off is a flow too (spec/26 §2 rule 2): a state parameter of step or on_stop labeled below the type it receives, as step(edit count: Int, ...) after init() -> secret Int, is U4001 at the parameter's type.

In edition 0.4, no label is checked in a policy's via function, but a deadline or race outcome may reach its result only if what runs beside it cannot time it (spec/07 §5 rule 7, ADR 0098): a within, first of, for ever within or limiter in a via body, or in code it calls, is U4001 at the site when the policy can be called beside other tasks, as in a branch of together, since whether the deadline passes or which branch wins would then release their timing at the label of the policy's to.

A via that calls a function value, or applies one whose code is not known at the call, reaches the code of every lambda and every function named as a value, so their timing sites count wherever the policy is called.

(Edition 0.3, ADR 0094 rule 7.) When the label comes from the answer of an operation that its binding labels with gives, the message and the first repair name that binding and operation, as "the answer of @service_files.owner, labeled internal[Service]", and the call is a related location.

How to fix it

The repair at a glance

diff
  module demo

- pub leak(pin: secret Int) -> Int = pin
+ pub keep(pin: secret Int) -> secret Int = pin

Failing example

una
module demo

pub leak(pin: secret Int) -> Int = pin

Fixed example

una
module demo

pub keep(pin: secret Int) -> secret Int = pin