E5005

E5005 — A call of a private function from another file, or such a function used as a value. A function, an associated function or a method with no pub is private to its file, as in Rust. A pkg function is visible to the files of its package only. So a library can keep a helper that only its own code may call, such as one that reads through a raw pointer.

What the compiler reports

Error[E5005] at {{.*}}.vx:25:19: `processes_of_the_program` is `pkg` in `process.vx`, so only the package `std` can call it

The fragments the test suite holds the compiler to. An ellipsis marks text the test does not constrain; the emitted message also carries a source location.

A program that triggers it

//
// Part of the Vx Project, under the Apache License v2.0 with LLVM Exceptions.
// See LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//
// A `Processes` is the right to start other programs. Only `std::process` can make one, and a
// program gets one in its `Root`. Code in another file cannot:
// - copy a `Processes` with an `impl Copy` (E3066),
// - make a `Processes` with a struct literal (E8014),
// - get the process right of the program, even in `unsafe`: only `std` can call
//   `processes_of_the_program` (E5005).
import std::process;

impl Copy for Processes {}

fn forged() -> Processes {
  return Processes {};
}

fn taken() -> Processes {
  return unsafe { processes_of_the_program() };
}

fn main() -> i32 {
  return 0;
}

From tests/frontend/fail/the_process_right_cannot_be_forged.vx, which asserts this diagnostic on every commit.

Related