Closed Bug 1437377 Opened 6 years ago Closed 6 years ago

Use dedicated error message when using "in" operator on non-string/non-object

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla60
Tracking Status
firefox60 --- fixed

People

(Reporter: arai, Assigned: arai)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

(Keywords: dev-doc-complete)

Attachments

(1 file)

The error message for `string in string` case is improved in bug 1352429,
but now it's a bit mis-leading for `string in undefined` or `string in null` case,
that should happen more in practice.

we should use more descriptive message for those cases.
Priority: -- → P3
Keywords: dev-doc-needed
Assignee: nobody → arai.unmht
Status: NEW → ASSIGNED
non-string/non-object cases:

  js> "foo" in undefined
  typein:1:1 TypeError: right-hand side of 'in' should be an object, got undefined
  js> "foo" in null
  typein:2:1 TypeError: right-hand side of 'in' should be an object, got null
  js> "foo" in 10
  typein:3:1 TypeError: right-hand side of 'in' should be an object, got number
  js> "foo" in true
  typein:4:1 TypeError: right-hand side of 'in' should be an object, got boolean
  js> "foo" in Symbol.iterator
  typein:5:1 TypeError: right-hand side of 'in' should be an object, got symbol

string case:

  js> "foo" in "bar"
  typein:6:1 TypeError: cannot use 'in' operator to search for 'foo' in 'bar'
Attachment #8952940 - Flags: review?(jwalden+bmo)
Attachment #8952940 - Flags: review?(jwalden+bmo) → review+
Pushed by arai_a@mac.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/ca314f76eb1c
Use dedicated error message when using "in" operator on non-string/non-object. r=jwalden
https://hg.mozilla.org/integration/mozilla-inbound/rev/ca314f76eb1cea65c3999a42960d57ef0eb3e78f
Bug 1437377 - Use dedicated error message when using "in" operator on non-string/non-object. r=jwalden
https://hg.mozilla.org/mozilla-central/rev/ca314f76eb1c
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla60
Depends on: 1780916
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: