Home / Docs / Diagnostics
U3020: Call into a boundary module whose capability is not granted with with
A call into a boundary module needs a capability that the call does not grant with with.
Why Una rejects it
From edition 0.3, una.toml can declare modules of the package as boundaries under [boundaries], and from edition 0.4 the boundaries section of ita.una does (ADR 0093): code the package's author does not control, such as a vendored library or a plug-in. No authority crosses a boundary by name.
A call into a boundary module, from any module outside its extent, does not meet the callee's uses from the caller's bindings by name. Every capability the callee needs is granted at the call with with, as a rebinding, a narrowed rebinding (@y[ops]) or a handler.
The same holds for:
- a function of a boundary used as a value outside it, at the reference;
- a handler of a boundary installed outside it, whose
usesare granted by another binding of the samewith.
An example's do line takes no with, so an example outside a boundary can call only boundary functions that need no capability.
How to fix it
The repair is a grant at the call, within the boundary's ceiling (U3021), narrowed to what the callee declares.
- When the ceiling allows every operation the callee needs and the caller holds a binding that permits them, the first repair is
with @x = @y[ops].una fixapplies it at a call that is its statement's whole expression, when@yis@xitself or the only binding that qualifies. - When several bindings qualify, the repair lists them and carries no edit: which resource the boundary receives is the consumer's decision.
- When the ceiling withholds an operation, no grant is offered. The repair is a handler whose own
useslie within the ceiling, and it names what the ceiling withholds.
Widening the caller's header or the ceiling is never the repair: the grant is what the consumer reviews, and the ceiling is the consumer's decision.
The repair at a glance
module demo.app
import demo.store (Files)
import demo.vendor (load)
pub open(path: Text) -> Text
uses @files: Files[read, write]
=
- load(path)
+ load(path) with @files = @files[read]Failing example
[package]
name = "demo"
version = "0.1.0"
edition = "0.3"
[boundaries]
"demo.vendor" = ["Files[read]"]module demo.store
pub capability Files
op read(path: Text) -> Text
op write(path: Text, data: Text) -> Unitmodule demo.vendor
import demo.store (Files)
pub load(path: Text) -> Text
uses @files: Files[read]
=
@files.read(path)module demo.app
import demo.store (Files)
import demo.vendor (load)
pub open(path: Text) -> Text
uses @files: Files[read, write]
=
load(path)Fixed example
[package]
name = "demo"
version = "0.1.0"
edition = "0.3"
[boundaries]
"demo.vendor" = ["Files[read]"]module demo.store
pub capability Files
op read(path: Text) -> Text
op write(path: Text, data: Text) -> Unitmodule demo.vendor
import demo.store (Files)
pub load(path: Text) -> Text
uses @files: Files[read]
=
@files.read(path)module demo.app
import demo.store (Files)
import demo.vendor (load)
pub open(path: Text) -> Text
uses @files: Files[read, write]
=
load(path) with @files = @files[read]