Skip to content
Playground(another site)

bynk.visibility.private_in_public

Error A public declaration's signature names a private type of its own unit, which an importer could neither name nor build.

A public declaration may not mention a private type of its own unit in its signature: a public function's parameters and return, a public type's fields and variant payloads, a public constant's type, or a context's exports list. A unit that uses the commons could neither name that type nor build a value of it, so the function would be half-usable. Make the type public, or make the declaration private too. Services, agents and capabilities are not checked here; a context's exports governs them.

Example

private type Tally = { lines: Int, sum: Int }
fn tally(n: Int) -> Tally { … } // ✗ public, but returns a private type
private fn tally(n: Int) -> Tally { … } // ✓ private too

In the Book

See also

  • The grammar rule it governs: visibility_modifier.
  • Every code in its category, Other, on the diagnostic index.
  • bynk explain bynk.visibility.private_in_public shows the same from the installed toolchain, without a network.