Skip to content

lint: hint when a define shadows a stdlib function the file has not imported #591

Description

@InauguralPhysicist

Follow-on from the STDLIB discoverability audit (2026-07-13).

Why. W013 already fires when a define shadows a compiled-in builtin (src/lint.c, "%s is a builtin — function definition shadows it"). But the far more common discoverability failure is redefining a stdlib library function the author never knew existed and never imported: DeslanStudio wrote define _pr_median / _pr_mean while lib/stats.eigs ships median/mean; hex4/pad2 were hand-rolled twice. The lint is silent on all of these because the name is not a builtin and the module was not imported, so nothing connects the local define to the stdlib function.

What. A new lint rule (e.g. W0xx, default-off or hint severity to avoid noise) that, when a program defines a function whose name matches a public stdlib function in lib/*.eigs that the file has NOT imported, emits: "define median shadows lib/stats.eigs median (import stats to use it)". Uses the same lib/ signature scrape proposed for LSP completion (#590) as its name table, so the two share one source of truth. Should respect the per-file allow-list (#455) and same-line # lint: allow (#556) like other W-rules.

Guardrails. Name-only matches will have false positives (a local mean that is deliberately different); hence hint severity / opt-in, and match only when the local define takes a compatible shape. This is a nudge toward the stdlib, not an error.

Acceptance. A file that define median as: ... without import stats gets the hint naming lib/stats.eigs; a file that imports stats and calls stats.median does not; the rule is suppressible per-file. Grounded in the repeated hand-roll evidence.

Source: 2026-07-13 stdlib discoverability audit (DX/docs).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions