Skip to content
Playground(another site)

bynk.visibility.private_item

Error A reference from another unit names a private declaration, which is visible only within its own unit and that unit's suites.

A private function, type, constant, asset or embed (or a private method) is visible only within its own unit, across all of that unit's files, and to the unit's suites. It is never visible through uses, so a unit that uses the commons cannot name it. The compiler reports that the name is private, not that it is unknown, so you know it exists. private keeps a helper out of the public surface, so it can change without breaking anyone. Call the commons' public function that does the job, or, if the item really belongs to the public surface, remove private where it is declared.

Example

pricing.bynk
commons pricing
fn total(items: List[Item]) -> Int { … }
private fn lineTotal(i: Item) -> Int { … }
// shop.bynk
commons shop
uses pricing
fn cost(i: Item) -> Int {
lineTotal(i) // ✗ `lineTotal` is a private function of `pricing`
total([i]) // ✓ the public function does the same job
}

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_item shows the same from the installed toolchain, without a network.