Skip to content

this is undefined inside a do…while body in non-class functions (breaks node-forge rsa_sign) #11724

Description

@proggeramlug

Found by the package matrix re-run (#11723): node-forge/rsa_sign throws TypeError: … (reading 'data'). Reproduces 3/3 at 9e29f59 and on origin/main 9e05951.

Inside a do…while body, this is undefined in any non-class function. A plain while loop works, and so does a class method.

const o = { d: 7, f(n) { let r = 0; do { r += this.d; n--; } while (n > 0); return r; } };
console.log(o.f(1)); // node: 7; perry: throws TypeError

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

    bugConfirmed defect or regression

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions