Warn about non-standard for-each regardless of JS version number

RESOLVED FIXED in Firefox 51

Status

()

defect
RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: arai, Assigned: arai)

Tracking

({dev-doc-complete, site-compat})

Trunk
mozilla51
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox51 fixed)

Details

Attachments

(2 attachments)

(Assignee)

Description

3 years ago
derived from bug 1083470.

now for-each is warning in parser depending on js version number

https://dxr.mozilla.org/mozilla-central/rev/763fe887c37cee5fcfe0f00e94fdffc84a41ea1c/js/src/frontend/Parser.cpp#6134
>             if (versionNumber() < JSVERSION_LATEST) {
>                 if (!report(ParseWarning, pc->sc->strict(), null(), JSMSG_DEPRECATED_FOR_EACH))
>                     return null();
>             }

we should warn regardless of the version number.
that will help add-on developers to migrate to standard syntax.
(Assignee)

Updated

3 years ago
Blocks: 1293305

Updated

3 years ago
Blocks: 1234048
(Assignee)

Comment 1

3 years ago
Removed versionNumber() check, and changed unused strict argument to false.
Also, made it warn-only-once, just like expression closure, to avoid flooding console.
Assignee: nobody → arai.unmht
Status: NEW → ASSIGNED
Attachment #8787291 - Flags: review?(evilpies)
Attachment #8787291 - Flags: review?(evilpies) → review+
It would be useful to add [Learn more] to the warning and then explain what the standardized alternatives to for-each are.

To do that, a new page needs to be written here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors and "JSMSG_DEPRECATED_FOR_EACH" and the URL needs to be added to https://dxr.mozilla.org/mozilla-central/source/devtools/server/actors/errordocs.js
(Assignee)

Comment 4

3 years ago
Added link to For-each-in_loops_are_deprecated page.
Attachment #8787585 - Flags: review?(fscholz)
Comment on attachment 8787585 [details] [diff] [review]
Part 2: Link to MDN documentation from for-each warning.

Awesome, thank you!
Attachment #8787585 - Flags: review?(fscholz) → review+
(Assignee)

Comment 6

3 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/4ab9576d4c6280d6f7dbbc75ea100d133ace1aad
Bug 1293205 - Part 1: Warn about non-standard for-each regardless of JS version number. r=evilpie

https://hg.mozilla.org/integration/mozilla-inbound/rev/3613d167d065e344e81fa6aab23492f71dd996d1
Bug 1293205 - Part 2: Link to MDN documentation from for-each warning. r=fscholz

Comment 7

3 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/4ab9576d4c62
https://hg.mozilla.org/mozilla-central/rev/3613d167d065
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
You need to log in before you can comment on or make changes to this bug.