Skip to content

Bundle emitter: a refused mutable droppable global that is never rebound gets an exact let fix-it #2369

Closed

Description

@ehartford

Context

Bundle Level 0 (D39) refuses a mutable global of a droppable type: nobody drops bundle storage (src/compiler/BundleInterfaceEmit.w, global_text: is_mut && type_needs_drop_frozen). D119 step 3 hit this in production shape: the migrator emitted tommyds' HASH32..INTHASH64 tables as pub var ... : List[...] and tommyds-wo-build failed. The migrator now spells a stable binding for a file-scope array (PR #2364), but hand-written code can still land on the bare refusal with no guidance toward the one-token fix.

Eric's question (2026-10-12): why doesn't the emitter just convert it? Answer recorded so it is not relitigated: var -> let changes the binding's meaning and the .wi fingerprint must agree with source (D65: a downstream stage never picks a meaning; defaults pick representations, never meanings). Auto-conversion would also hide the drop problem for bundle-internal rebinding. The emitter refuses loudly — that part is right.

Proposal

When the emitter refuses a mutable droppable global, check Sema's evidence for whether the binding is ever rebound (whole-binding assignment). Interior mutation — field/index writes, mut self calls — is fine under a stable binding (spec §9.1c), so it does not block the suggestion; only reassignment of the binding itself does. Sema already records global writes (global_write_records / record_global_place_write in SemaCheck, built for the §9.1c/§21.1 race rules); the diagnostic needs the rebound-vs-interior distinction from that data, completed if necessary (note the std/runtime-module carve-out in record_global_data_race_access).

  • Never rebound: the refusal names the exact fix: spell it let (a stable binding), e.g. pub let HASH32: List[hash32_test], and notes that interior writes remain legal under §9.1c.
  • Rebound somewhere: refusal unchanged (no suggestion, or names the rebinding site so the author sees why let is not available).

The .wi spelling is never altered by the emitter; the programmer (or migrator) makes the change at the source.

Acceptance

  • A bundle-interface-tests refusal case: a pub var List global that is only read or written in place refuses with the let fix-it in the message.
  • A second case: a pub var List global that some body rebinds refuses without the fix-it (ideally naming the rebinding site).
  • Fingerprint behavior unchanged; no silent conversion anywhere.

Activity

  1. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-10-25, with v0.15.3.0 (main a261b65): reproduced in source: the refusal (src/compiler/BundleInterfaceEmit.w:538-539) still reads "is a mutable global of a droppable type (…); nobody drops bundle storage (Level 0)" with no fix-it, even when the global is never rebound.

    post-release: it reaches only bundle authors, and the migrator already emits the stable binding (#2364).

  2. added this to the post-v0.16.0 milestone on Oct 28, 2026
  3. added a commit that references this issue on Nov 11, 2026
  4. ehartford commented on Nov 11, 2026

    @ehartford
    ContributorAuthor

    Fixed in #3257. Sema records the first site that rebinds a mutable global whole (global_rebind_sites). The refusal now ends 'no body rebinds it, so spell it let (pub let TABLE: List[i32])' or 'it is rebound at :, so it cannot be a let'. The emitter still never changes the spelling. Tests: bundle-interface-tests wi_refuse_var_droppable, wi_refuse_var_rebound.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions