Skip to content

Bundle interface fns leak past the §18.2 prelude gate, and a same-named user fn shares their flat signature (audit:all fails) #1362

Closed

Description

@ehartford

Found while fixing #1350. Pre-existing on the installed compiler and on main.

1. Bundle internals are callable with no import (§18.2 / D29 gate leak)

fn main:
    print(f"{u128_mul_would_overflow(1, 2)}")

with run prints false. u128_mul_would_overflow is a pub helper in the migrated bundle corpora (lib/std/re/defs.w, zl, tommyds, c_algorithms), reachable only through the prelude's use std.regex → std.re.*. It is not an enumerated prelude name (sema_prelude_gate_allows_name, Sema.w), so per §18.2 / D29 it must need an explicit import. Same for is_alnum, is_xdigit, to_lower, ... : print(f"{is_alnum(33)}") compiles with no use std.string.is_alnum, because the on-demand .wi merge (Frontend.w merge_interface_sections_on_demand) brings in std.re.defs's interface is_alnum, and decl_visible_from_current_gated does not apply the prelude gate to it (module_in_prelude_closure is false for the bundle module) — visibility passes through std.re.defs while the call binds std.string's flat signature.

Expected: a user program names bundle-corpus internals only through an explicit import (or not at all); closing the leak will break programs that call is_alnum/is_digit unimported today, so the behavior change needs a ruling on sequencing (fix-it use std.string.is_alnum exists already).

2. A user fn named like an interface fn: two signatures under one flat symbol

fn is_digit(ch: u8) -> bool: ch > 1
fn main:
    print(f"{is_alnum(33)}")

with analyze x.w audit:all:

violation: declaration is_digit sig=222 param=0: finalized source type or LLVM parameter disagrees with FnAbi

The on-demand interface merge parses every bundle .wi is_digit the source mentions; SemaDecl's D39 interface_yields keeps the interface signature (i32) under the same flat symbol as the user's is_digit(u8), and the codegen audit (audit_declared_share_place_contracts, Codegen.w) checks that sig against the user's function. #1350's fix gives source fns a module-qualified identity when another module takes the short name (name$in$<module>, Frontend.w frontend_displace_fn_decl, link name unchanged via fn_abi_module_link_name); applying the same displacement to interface decls fixes (2) but also closes (1) for colliding names only, so it waits for the ruling on (1) rather than half-closing the gate.

Spec: §18.1 name precedence; §18.2 prelude; D29; D39.

Activity

  1. added a commit that references this issue on Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions