Skip to content
Playground(another site)

bynk.types.opaque_unsafe_outside

Error .unsafe on an opaque type was used outside its defining context.

T.unsafe(v) wraps a base value as an opaque type without checking it, which is sound only where the type's own unit vouches for the value, so it is allowed only in the unit that declares the type. Elsewhere use T.of(v), which returns a Result so the check is explicit. Reading the base value back is bynk.types.opaque_raw_outside.

Example

token.bynk
type Token = opaque String
// app.bynk
fn make(s: String) -> Token {
Token.unsafe(s) // ✗ only `token` may skip the check
}
fn make(s: String) -> Result[Token, ValidationError] {
Token.of(s) // ✓ the checked constructor
}

In the Book

See also

  • The grammar rule it governs: field_access.
  • Every code in its category, Type checking, on the diagnostic index.
  • bynk explain bynk.types.opaque_unsafe_outside shows the same from the installed toolchain, without a network.