Issue #2837: A program can call BigInt’s consuming twins add_own / sub_own / neg_own / abs_own by name, against ADR-text-reuse-1 D6

Open and answer this issue on GitHub.

performance, ready · opened 2026-11-23 · updated 2026-11-23 · 0 comments

What is wrong

ADR-text-reuse-1 D6 says: “The method a program writes stays the one method; the twin is no name a program can call (one way to say it, as in D4).”

The work on “BigInt arithmetic works in a dead operand’s buffer” (#2823) kept the twins out of std.contracts, and that was how no program could name them. The QA fix for the red suite on 6a5ac170 (commit a42aa1c9, “std.contracts: entries for the BigInt *_own twins …”) then added them to the ledger with pub = true, because the_shipped_std_ledger_agrees_with_its_nikaia_sources requires every pub fn of bigint.nika to have a ledger entry. Since that commit a program can call them.

Probe

use std::bigint

fn main() throws {
    let a = bigint::BigInt::of(5)
    let b = bigint::BigInt::of(7)
    let c = a.add_own(b)
    let d = c.add(bigint::BigInt::of(1))
}

Why this needs the compiler, not std

The twins have to stay pub, because the emitted call in the user crate reaches them. They also have to be in the ledger, because the ledger agrees with the source. What is missing is a way to mark a ledger entry as a lowering target that a program cannot name.

To build

  1. A mark on the twin in bigint.nika that the_shipped_std_ledger_agrees_with_its_nikaia_sources carries into the ledger entry. Name the method it twins, e.g. twin_of = "add", in the same form as the other entry keys. The emitter’s choice of twin can then read that mark instead of a name list, if it uses a list today.
  2. Name resolution for a method call (the NK1171 path) refuses a method whose entry carries the mark, with NK1171 as for an unknown method. The note says the method is the lowering of add and is written add.
  3. --tethers and D6’s lowering keep working unchanged: bigint_add_at_last_use and tethers_narrate_consuming_twins stay green.
  4. Revert the doc comment in bigint.nika (from a42aa1c9) to say no program can name the twins.
  5. New test tests/compiler/tests/bigint_twin_not_nameable.nika with .stderr: the probe above, refused.

Done when

The probe is refused with NK1171, the ledger test is green, and the two D6 tests are unchanged.

Back to Open Issues