Fix unsafe `instanceof` negations

RESOLVED FIXED in Firefox 53

Status

()

Toolkit
General
RESOLVED FIXED
a year ago
a year ago

People

(Reporter: kitcambridge, Assigned: kitcambridge)

Tracking

unspecified
mozilla53
Points:
---

Firefox Tracking Flags

(firefox53 fixed)

Details

MozReview Requests

()

Submitter Diff Changes Open Issues Last Updated
Loading...
Error loading review requests:

Attachments

(2 attachments)

Some of our modules use the pattern `!value instanceof Class`, to check if `value` is not an instance of `Class`.

This isn't quite right: `!` binds tighter than `instanceof`, so that will evaluate to `false instanceof Class`...which will always be false (https://github.com/DavidBruant/ECMAScript-regrets/issues/27).

We need an extra set of parens to make this work: `!(value instanceof Class)`.
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)

Comment 4

a year ago
mozreview-review
Comment on attachment 8817932 [details]
Bug 1322954 - Fix incorrect `instanceof` negations.

https://reviewboard.mozilla.org/r/98100/#review98410

wow - it's scary how often we weren't checking what we thought we were checking!
Attachment #8817932 - Flags: review?(markh) → review+

Comment 5

a year ago
mozreview-review
Comment on attachment 8817933 [details]
Bug 1322954 - Replace deprecated `no-negated-in-lhs` ESLint option with `no-unsafe-negation`.

https://reviewboard.mozilla.org/r/98102/#review98412

This looks great, but will require another try.
Attachment #8817933 - Flags: review?(markh) → review+
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)

Comment 8

a year ago
Pushed by kcambridge@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/4d6f11e28343
Fix incorrect `instanceof` negations. r=markh
https://hg.mozilla.org/integration/autoland/rev/2c1d9731a014
Replace deprecated `no-negated-in-lhs` ESLint option with `no-unsafe-negation`. r=markh

Comment 9

a year ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/4d6f11e28343
https://hg.mozilla.org/mozilla-central/rev/2c1d9731a014
Status: ASSIGNED → RESOLVED
Last Resolved: a year ago
status-firefox53: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
You need to log in before you can comment on or make changes to this bug.