Home / Docs / Diagnostics

U3012: Host capability in main not granted by una run

Release v0.4.0

A uses clause of main names a host operation that no grant allows.

Why Una rejects it

Host capabilities enter a program only through the uses of main, and una run grants only the capabilities listed in --grant flags or in the package's grants: [run] grants in una.toml, or from edition 0.4 the grants line of the run section of ita.una (spec/04 §8, spec/05 §7).

How to fix it

The repair at a glance

una.tomldiff
  [package]
  name = "demo"
  version = "0.1.0"
  edition = "0.1"

  [run]
  entry = "demo"
- grants = ["console"]
+ grants = ["console", "clock"]

Failing example

una.tomltoml
[package]
name = "demo"
version = "0.1.0"
edition = "0.1"

[run]
entry = "demo"
grants = ["console"]
src/demo.unauna
module demo

pub main() -> Unit
  uses @console: Console[print]
  uses @clock: Clock[now]
=
  let now = @clock.now()
  @console.print("now: {now}")

Fixed example

una.tomltoml
[package]
name = "demo"
version = "0.1.0"
edition = "0.1"

[run]
entry = "demo"
grants = ["console", "clock"]
src/demo.unauna
module demo

pub main() -> Unit
  uses @console: Console[print]
  uses @clock: Clock[now]
=
  let now = @clock.now()
  @console.print("now: {now}")