Skip to content

CommonJS model: Rule 2 misses unions with absent, loses reasons in union(), and treats depth cutoffs as complete #32

Open

Description

@inth3shadows

Found in the PR #29 round-14 review. Rule 2 bails a file when an unknown is reachable from its exports, but some incomplete answers are not unknowns:

  1. Union with absent. function run(){} if (typeof window === 'undefined') exports.run = run; gives run = union[run, absent]. That member is not unknown, so the file stays modelled, the union select rejects it, and the pre-PR edge go → m.js:run is lost.
  2. union() drops the reason. CommonJsValueGraph.union returns unknown('unknown alternative'). A conditional if (process.env.X) patch(exports) therefore bails to the pre-PR graph, with its wrong decoy edges, while the unconditional patch(exports) stays ruled no-edge. Whether the opaque-call ruling applies depends on the if.
  3. Depth cutoffs count as complete. forwardsOutside (seen.size >= 8) and incomplete() (depth > 8) treat their cutoff as "inside the model". A chain f0→…→f10 of module.exports = require(...) ending in ESM loses go → f10.js:run.

Fix direction: count absent-in-union as incomplete; keep a blocking reason through union (e.g. a set of reasons); treat any cutoff as unmodelled.

Activity

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