Skip to content

CommonJS model: destructuring and for-in/of targets that write exports are not seen #31

Open

Description

@inth3shadows

Found in the PR #29 round-14 review. Rule 1's write detection only recognises = / compound assignment and ++/--, and write() ignores a non-member LHS. Destructuring and for-in/for-of targets that write an exports member are therefore read as no write: the file stays modelled and the member answers absent.

Repros (each loses the pre-PR edge run → m.js:b):

  • exports.a=a; [exports.b]=[b];
  • ({x: exports.b} = {x: b});
  • for (exports.b of [b]); and for (exports[k] in o);
  • nested: function init(){ [exports.b]=[b]; } init();

Fix direction: treat any binding/assignment-pattern or for-in/of initializer target rooted at exports (or an exported value) as a write; at top level model it or bail, and when nested, bail.

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