Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-473

Assigning members to this outside of constructor works but should be forbidden

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • 0.12.0
    • Affects Version/s: 0.5.2
    • Component/s: AsyncWriter
    • Labels:
      None
    • Not Needed

      Problem Description

      There is a test case (https://github.com/mongodb-js/mongosh/blob/master/packages/async-rewriter/src/async-writer-babel.spec.ts#L2880) that should verify that an error is thrown if an assignment to a class member happens outside the constructor using the this keyword.

      However, the test case passes - but no error is thrown. The test case is missing a fail() call after the compileCheckScopes.

      Steps to Reproduce

      Run the async-writer tests

      Expected Results

      The referenced test case passes because an error is thrown.

      Actual Results

      The referenced test cases passes since no error is thrown and an explicit fail is missing.

      Additional Notes

      The fix should probably be placed inside this if statement: https://github.com/mongodb-js/mongosh/blob/master/packages/async-rewriter/src/async-writer-babel.ts#L306. The check whether the assignment is inside a constructor is missing here.

            Assignee:
            Unassigned Unassigned
            Reporter:
            michael.rose@mongodb.com Michael Rose (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: