Closed Bug 1863308 Opened 11 months ago Closed 10 months ago

Confusing error when using `case` as a variable name in for loop initializer

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
122 Branch
Tracking Status
firefox122 --- fixed

People

(Reporter: emilio, Assigned: jon4t4n)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

for (let case of ["removed", "changed"]) {}

Says:

Uncaught SyntaxError: missing ; after for-loop initializer

Which was very confusing until I realized case is a JS keyword.

V8 says:

Uncaught SyntaxError: Unexpected token 'case'

Which is a bit less confusing.

Type: task → defect
Severity: -- → N/A
Type: defect → enhancement
Priority: -- → P3
Assignee: nobody → jonatan.r.klemets
Status: NEW → ASSIGNED
Pushed by arai_a@mac.com: https://hg.mozilla.org/integration/autoland/rev/6d8cf3ece335 Improve error message when using reserved word in `for (let ...)` r=arai
Status: ASSIGNED → RESOLVED
Closed: 10 months ago
Resolution: --- → FIXED
Target Milestone: --- → 122 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: