Class redeclaration error message mentions "let" as cause

RESOLVED FIXED in Firefox 58

Status

()

P3
normal
RESOLVED FIXED
3 years ago
a year ago

People

(Reporter: fscholz, Assigned: mcdonalds.only, Mentored)

Tracking

(Blocks: 1 bug, {triage-deferred})

unspecified
mozilla58
triage-deferred
Points:
---

Firefox Tracking Flags

(firefox58 fixed)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

3 years ago
In case you redeclare a class, the error message mentions `let` as the cause, which can be misleading when debugging. There is no `let` here at all:

> class Foo {}; class Foo {};

Firefox:
> SyntaxError: redeclaration of let Foo

Chrome:
> Uncaught SyntaxError: Identifier 'Foo' has already been declared

A more generic term like "identifier" works. If we can be specific, we could mention a "class redeclaration".
(Reporter)

Updated

3 years ago
Blocks: 622261
Keywords: triage-deferred
Priority: -- → P3
(Assignee)

Comment 1

a year ago
I'm working on this.
Thank you!
Assignee: nobody → mcdonalds.only
Mentor: arai.unmht
Status: NEW → ASSIGNED
(Assignee)

Comment 3

a year ago
Created attachment 8923681 [details] [diff] [review]
Clarify error message for redeclaration of class

If you redeclare a class, you will get following error message.

> class Foo {}; class Foo {};

> SyntaxError: redeclaration of let Foo

In this patch, you will get following clearer error message instead of above one.

> SyntaxError: redeclaration of class Foo

I added `Class` to `DeclarationKind` and `BindingKind`, but class is handled as same as `let` after parsing, which is the same way as before.
Attachment #8923681 - Flags: review?(arai.unmht)
Comment on attachment 8923681 [details] [diff] [review]
Clarify error message for redeclaration of class

Review of attachment 8923681 [details] [diff] [review]:
-----------------------------------------------------------------

Thank you for your patch :D
As talked in person, the change to BindingKind seems to be unnecessary for error reporting.
(BindingKind's string representation is used in EmitterScope::dump, but it's only for debug purpose, and not exposed to web developers, so keeping it "Let" should be fine)
Attachment #8923681 - Flags: review?(arai.unmht) → feedback+
(Assignee)

Comment 5

a year ago
Created attachment 8923685 [details] [diff] [review]
Clarify error message for redeclaration of class

Thank you for your review!
I discarded changes to BindingKind.
Attachment #8923681 - Attachment is obsolete: true
Attachment #8923685 - Flags: review?(arai.unmht)
Comment on attachment 8923685 [details] [diff] [review]
Clarify error message for redeclaration of class

Review of attachment 8923685 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks again!

Here's try run (automation for build and test),
when it runs without failure, feel free to add "checkin-needed" keyword to this bug, so this patch will be landed shortly.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=7a89ff3c10296385c476f70d8a06881e48bb9cfe
Attachment #8923685 - Flags: review?(arai.unmht) → review+
Keywords: checkin-needed

Comment 7

a year ago
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/dafc1282a533
Clarify error message for redeclaration of class. r=arai
Keywords: checkin-needed

Comment 8

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