# V3030 effect_ceiling_exceeded

URL: /docs/errors/V3030
Markdown: /docs/errors/V3030.md

> A pub fn of a package requires a std effect that the package's ceiling does not list (RFC 0003 §5.1, experimental).

An error from the `effect` phase. `sakura explain V3030` prints this explanation offline.

A `pub fn` of a package requires a std effect that the package's ceiling does not list (RFC
0003 §5.1, experimental). `[package] effects` in `sakura.toml` is the ceiling: the std effects
the package's public functions may require. The check unions the std effects in every `pub fn`'s
row (user-defined effects, `Fail` and `Test` are not counted) and reports each `pub fn` whose row
goes beyond the ceiling. A package without an `effects` key has no ceiling and no check; `effects
= []` is a pure package. Either remove the effect from the function or widen the ceiling, which
every consumer then has to accept on its dependency line (`V8032`).

Wrong:

```sakura
# sakura.toml
[package]
name = "stamp"
effects = ["Clock"]
# src/lib.sak
pub fn log_now() -> Unit ! {Clock, Console} { Console.print("{Clock.monotonic_micros()}") }
```

Fixed:

```sakura
pub fn now() -> Int ! {Clock} { Clock.monotonic_micros() }
```

## Wrong program [#wrong-program]

[`compiler/tests/ui/V3030_effect_ceiling_exceeded/`](https://github.com/icantcodefyi/sakuralang/blob/main/compiler/tests/ui/V3030_effect_ceiling_exceeded/), which the compiler's ui suite runs through `sakura check`:

`lib.sak`:

```sakura
// RFC 0003 §5.1: a `pub fn` whose row has a std effect beyond `[package] effects` is `V3030` at
// the function; private functions and user-defined effects do not count.

pub fn log_now() -> Unit ! {Clock, Console} { Console.print("{Clock.monotonic_micros()}") }

pub fn now() -> Int ! {Clock} { Clock.monotonic_micros() }

fn shout(s: String) -> Unit ! {Console} { Console.print(s) }
```

`sakura.toml`:

```toml
[package]
name = "stamp"
version = "0.1.0"
effects = ["Clock"]
```

`sakura check --json` reports this record (pretty-printed; `$DIR` is the fixture's directory):

```json
{
  "schema_version": "1.0",
  "kind": "diagnostic",
  "id": "d:cba4f439b92e9161",
  "code": "V3030",
  "severity": "error",
  "phase": "effect",
  "message": "`pub fn log_now` requires `Console`, beyond package `stamp`'s ceiling `effects = [\"Clock\"]` in sakura.toml",
  "snapshot": "sha256:$SNAPSHOT",
  "symbol_id": "stamp::lib::log_now",
  "spans": [
    {
      "uri": "file://$DIR/V3030_effect_ceiling_exceeded/lib.sak",
      "content_hash": "sha256:48ea78361f48c268839fd684731a196eae0cc567be4d5e81f1dbaf6c05236eb1",
      "start_byte": 223,
      "end_byte": 230,
      "role": "primary"
    }
  ],
  "related_ids": [],
  "expected": null,
  "actual": null,
  "obligation": null,
  "counterexample": null,
  "explanation_uri": "sakura://explain/V3030",
  "fixes": []
}
```

## Fixed program [#fixed-program]

No fixed program is checked in for this code yet; the explanation above describes the repair.
