Skip to content

CommonJS model: loops, switch, short-circuit and try writes are modelled as straight-line #30

Closed as not planned

Description

@inth3shadows

Found in the PR #29 round-14 review. The CommonJS value model walks top-level code as straight-line, so a write that may never run replaces the real export, and the file stays modelled with a wrong answer. Only if and logical assignment fork the graph.

Repro: m.js function run(){} exports.run = run; for (const k of []) exports.run = 42; with c.js const {run} = require('./m'); const lib = require('./m'); function go(){ run(); lib.run(); }.

  • Pre-PR: go → m.js:run (x2).
  • PR29: no edge, because run is modelled as data 42.

Same with switch arms, cond && (exports.run = 1), ?: and try bodies written after the real write.

Fix direction: fork the graph for these constructs, or treat an exports write inside them as an unmodelled use (Rule 1), which makes the file resolve as pre-PR.

Activity

  1. inth3shadows commented on Nov 17, 2026

    @inth3shadows
    OwnerAuthor

    Closing as moot: this tracked a gap in the CommonJS export model from #29, which is closed (see the closing note there). The CommonJS work continues in #28.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions