Closed Bug 1282431 Opened 7 years ago Closed 5 years ago

Class redeclaration error message mentions "let" as cause

Categories

(Core :: JavaScript Engine, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla58
Tracking Status
firefox58 --- fixed

People

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

References

(Blocks 1 open bug)

Details

(Keywords: triage-deferred)

Attachments

(1 file, 1 obsolete file)

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".
Blocks: jserror
Keywords: triage-deferred
Priority: -- → P3
I'm working on this.
Thank you!
Assignee: nobody → mcdonalds.only
Mentor: arai.unmht
Status: NEW → ASSIGNED
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+
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+
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
https://hg.mozilla.org/mozilla-central/rev/dafc1282a533
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
You need to log in before you can comment on or make changes to this bug.