Skip to content

Retire the twelve hand registrations the generated registrar shadows #696

Description

@mparrett

Child of #531 (S2). Fast-follow from #686.

#686 landed TestNoNewShadowedHandRegistrations, which pins the set of names registered twice: once by hand in installLangNS, once by a //lg:native decl in native_prims.go. The generated registrar drains after installLangNS, so it takes the var root and the hand-written closure never runs. That list is a ratchet against new duplicates; it does not resolve the existing ones.

Twelve names are on it:

name hand registration in lang.go generated decl
conj ns.Def("conj", conj) Conj
deref ns.Def("deref", deref) Deref, Deref3
get ns.Def("get", get) Get, Get3
int ns.Def("int", intf) Int
name ns.Def("name", name) Name
namespace ns.Def("namespace", namespace) Namespace
nth ns.Def("nth", nthf) Nth, Nth3
pop-binding! ns.Def("pop-binding!", popBinding) PopBinding
push-binding! ns.Def("push-binding!", pushBinding) PushBinding
some ns.Def("some", some) Some
str ns.Def("str", str) Str
subs ns.Def("subs", subs) Subs, Subs3

Why close them

reduce was the thirteenth. Its two bodies had drifted: the closure carried an ArrayVector fast path, a Range fast path, and a reused argument buffer that the //lg:native decl never got. When #639's namespace-alias fix made the generated registration resolve for the first time, reduce silently switched to the naive body and got 1.88x slower, with no diff to reduce and no failing test. TestReduceRangeFastPath stayed green: it asserts results, not which path produced them (#656).

A second copy that nothing executes has no pressure keeping it honest.

What the audit found

All twelve pairs were compared body for body during #686. The //lg:native decls are faithful ports, several carrying the closure's comments verbatim. No name is losing behavior today, so this is deletion work rather than porting work, and it can go at whatever pace suits.

Shape of the work

Per name, or per small family:

  1. Delete the ns.Def site.
  2. Delete the Go func it referenced, once nothing else calls it.
  3. Drop the name from knownShadowedHandRegistrations.

The ratchet keeps the list honest in both directions: a new duplicate fails the test, and a listed name that is no longer double-registered fails it too, so the list cannot go stale.

Done when the accepted set is empty and the test asserts emptiness directly.

Gate

ns-publics diff empty, pkg/rt green under go test -count=2. The failure mode to watch for is deleting a var's only surviving registration, which the ns-publics diff catches.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions