---
title: "U4002: Implicit flow through control, failure or call under raised pc"
url: https://una-lang.org/en/docs/errors/U4002/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U4002.md
---

# U4002: Implicit flow through control, failure or call under raised pc

A failure, a call or a policy call appears inside a branch on a labeled value, where the program counter does not allow it. The message names the construct and the label; its related location is the condition. In a program that starts tasks, U4002 also reports a check point that data above `internal` decide.

## Why Una rejects it

Inside the branches of an `if`, `when` or `if none` on a labeled value, the program counter carries that label (`spec/07 §3`). A failure there would reveal which branch ran, so:

- `fail`, `if error fail`, `if error pass`, `if none fail` and `checked` on a labeled value are allowed only under a `public` program counter.
- A call is allowed only when the program counter is below the callee's `bound`, which is `public` for a function that can fail and the lowest `accepts` of its effects otherwise.
- A policy call is allowed only when the program counter is below its `to` label.

(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.

In a program that starts tasks (edition `0.4`, `spec/27 §8` rule 5), the schedule moves from one task to the next after a count of check points: calls of Una code, operations, loop iterations and the elements that `map`, `filter`, `first_where` and `fold` visit. A check point that data above `internal` decide would let that data order the tasks' later prints and trace events. Such a check point is, for example, a call inside a branch on a `secret` value, a loop whose bound is `secret`, a `map` over a `secret` list or a call of a function value chosen by a `secret` value. So it is U4002 in a package:

- whose code holds a `tasks` statement,
- that has a `serve` section (its driver runs each request as a started task), or
- that calls a dependency not checked with it.

So is a call of a generic function or of `first_where`, or of code the label rules do not check, whose function argument returns such data, and a `tasks at most n at once` whose `n` is such data.

The rule is coarse: a branch whose two sides pass as many check points is refused too.

Data at `internal`, as the requests of `HttpServer`, are not refused, so they can still order the effects of started tasks, a known residual (#1708). `una report` lists each such check point in `information.timing` as a `task switch` at `internal`.

## How to fix it

Code that must branch on labeled data returns a labeled value instead of failing.

When the label comes from the answer of an operation that its binding labels with `gives`:

- Read the operation through a binding that answers within the label it would reveal.
- Move the code out of the branch on the answer.
- Last, release the answer through a policy of a trusted module.

In a program that starts tasks:

- Compute on data above `internal` without the calls, operations and loops it decides: a loop over a `public` range whose body only assigns, or a branch that only picks a value.
- Or do the work in a program without `tasks`.

## The repair at a glance

```diff
  module demo

- kind PinError = | Rejected
-
- pub check(pin: secret Int) -> secret Int
-   fails PinError
- =
-   if pin == 1234
-     1
-   else
-     fail Rejected
+ pub check(pin: secret Int) -> secret Bool = pin == 1234
```

## Failing example

```una
module demo

kind PinError = | Rejected

pub check(pin: secret Int) -> secret Int
  fails PinError
=
  if pin == 1234
    1
  else
    fail Rejected
```

## Fixed example

```una
module demo

pub check(pin: secret Int) -> secret Bool = pin == 1234
```
