Improve numeric separators error messages
Categories
(Core :: JavaScript Engine, task, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox72 | --- | fixed |
People
(Reporter: fs, Assigned: rohitawate121, Mentored)
Details
(Keywords: good-first-bug, Whiteboard: lang=C++)
Attachments
(4 files, 1 obsolete file)
We seem to throw this in most cases:
- "SyntaxError: missing digit after '_' numeric separator"
Chrome throws nicer messages:
- "Numeric separators are not allowed at the end of numeric literals" for 1_
- "Only one underscore is allowed as numeric separator" for 1__1
Separator after null is fine, I guess. At least it's handled with an own message by us as well:
- Firefox: "numeric separators '_' are not allowed in numbers that start with '0'"
- Chrome: "Numeric separator can not be used after leading 0."
I think what Chrome throws for 1_
and 1__1
is better. Should we create nicer error messages for these cases as well?
Updated•4 years ago
|
Comment 1•4 years ago
|
||
The fix is simple: check for '_'
here and then replace the error message here with two different error messages.
Plus a test. Want to give it a shot?
Assignee | ||
Comment 2•4 years ago
|
||
Hi! I'm new around here. I would like to give this a shot.
Comment 3•4 years ago
|
||
(In reply to Jason Orendorff [:jorendorff] from comment #1)
The fix is simple: check for
'_'
here and then replace the error message here with two different error messages.Plus a test. Want to give it a shot?
Hi Jason, I wanna make sure I understand the issue correctly.
We need to replace the error message to two different cases of error messages, So we need to separately check for successive '' and another check for '' at the end of numeric literals?
Comment 4•4 years ago
|
||
(In reply to Ahmad Ganzouri from comment #3)
(In reply to Jason Orendorff [:jorendorff] from comment #1)
The fix is simple: check for
'_'
here and then replace the error message here with two different error messages.Plus a test. Want to give it a shot?
Hi Jason, I wanna make sure I understand the issue correctly.
We need to replace the error message to two different cases of error messages, So we need to separately check for successive'_'
and another check for'_'
at the end of numeric literals?
Note Updated for '_'
typo.
Assignee | ||
Comment 5•4 years ago
|
||
(In reply to Ahmad Ganzouri from comment #4)
(In reply to Ahmad Ganzouri from comment #3)
(In reply to Jason Orendorff [:jorendorff] from comment #1)
The fix is simple: check for
'_'
here and then replace the error message here with two different error messages.Plus a test. Want to give it a shot?
Hi Jason, I wanna make sure I understand the issue correctly.
We need to replace the error message to two different cases of error messages, So we need to separately check for successive'_'
and another check for'_'
at the end of numeric literals?Note Updated for
'_'
typo.
Hi Ahmad! I've been working on this issue since Saturday. I already have a patch ready and have been awaiting Jason's green signal.
Comment 6•4 years ago
|
||
Rohit, just post your patch here. After that only mentors can review it.
Kind Regards
Sonia
Assignee | ||
Comment 7•4 years ago
|
||
Assignee | ||
Comment 8•4 years ago
|
||
Thanks Sonia! I was of the impression that the bug needs to be assigned before submitting any patches.
Just submitted the patch. I hope I'm doing this correctly because I'm a bit confused. Am I supposed to be using Phabricator for patches and code reviews?
Assignee | ||
Comment 9•4 years ago
|
||
Assignee | ||
Comment 10•4 years ago
|
||
Depends on D50902
Comment 11•4 years ago
|
||
Hi Rohit,
Wait for the reviews now :) And that depends on you whether you want to use arc
or moz-phab
for submitting patches.
Comment 12•4 years ago
|
||
Hi Rohit, I think something went wrong the the patches. Can you merge these changes in a single patch? Thanks!
Assignee | ||
Comment 13•4 years ago
|
||
Thanks Sonia! :)
Hi Jan, yes I messed that up. Really sorry! This is the first time I'm working with Mercurial and Phabricator. Could you please guide me as to how I could merge the two patches?
Comment 14•4 years ago
|
||
(In reply to Rohit Awate from comment #13)
Hi Jan, yes I messed that up. Really sorry! This is the first time I'm working with Mercurial and Phabricator. Could you please guide me as to how I could merge the two patches?
No worries. How did you submit the patches? The recommended way is to use moz-phab
and then you can amend commits and run moz-phab again to update the Phabricator patch, see https://moz-conduit.readthedocs.io/en/latest/phabricator-user.html
Assignee | ||
Comment 15•4 years ago
|
||
I used moz-phab
, however, I did not amend the first commit while adding some changes. Instead, I made a separate commit which ended up as a separate diff on Phabricator. How should I merge the patches on Phabricator now?
Thanks! :)
Comment 16•4 years ago
|
||
(In reply to Rohit Awate from comment #15)
I used
moz-phab
, however, I did not amend the first commit while adding some changes. Instead, I made a separate commit which ended up as a separate diff on Phabricator. How should I merge the patches on Phabricator now?
You should merge the patches locally. One option is to hg update
to the first commit, make your changes, then hg commit --amend
, then moz-phab
.
(I'd recommend using the Mercurial evolve extension, it adds hg amend
and some other useful commands.)
Assignee | ||
Comment 17•4 years ago
|
||
(In reply to Jan de Mooij [:jandem] from comment #16)
(In reply to Rohit Awate from comment #15)
I used
moz-phab
, however, I did not amend the first commit while adding some changes. Instead, I made a separate commit which ended up as a separate diff on Phabricator. How should I merge the patches on Phabricator now?You should merge the patches locally. One option is to
hg update
to the first commit, make your changes, thenhg commit --amend
, thenmoz-phab
.(I'd recommend using the Mercurial evolve extension, it adds
hg amend
and some other useful commands.)
Thanks! I tried hg update
followed by hg commit --amend
, but it says abort: cannot amend changeset with children
.
I tried another way on a dummy repository: hg strip --keep -r .
which removes the last commit and then hg commit --amend
. This did work. Do you think this will work well with Phabricator and if it is a good way?
Also, would pushing this patch to Phabricator remove the duplicate patch I had created before on there? (#D50904, specifically)
I'm sorry for asking these really stupid questions but I don't want to mess up on Phabricator again. Really appreciate your patience and help!
Comment 18•4 years ago
•
|
||
(In reply to Rohit Awate from comment #17)
Thanks! I tried
hg update
followed byhg commit --amend
, but it saysabort: cannot amend changeset with children
.
I tried another way on a dummy repository:hg strip --keep -r .
which removes the last commit and thenhg commit --amend
. This did work. Do you think this will work well with Phabricator and if it is a good way?
I think that will be fine. moz-phab should update the first revision. If it does create a new revision we can just close the first two and no harm is done.
Also, would pushing this patch to Phabricator remove the duplicate patch I had created before on there? (#D50904, specifically)
No, but you can just 'abandon' the second patch on Phabricator (look for the Add Action...
box).
I'm sorry for asking these really stupid questions but I don't want to mess up on Phabricator again. Really appreciate your patience and help!
No problem! Thanks for working on this. You can also ask questions in the #jsapi channel on Mozilla's IRC server.
Comment 19•4 years ago
|
||
Also, for future changes, consider using the Mercurial evolve extension. hg amend
does let you amend changesets with children.
Assignee | ||
Comment 20•4 years ago
|
||
Assignee | ||
Comment 21•4 years ago
|
||
Hi Jan, thanks for all the help! Really appreciate it.
I learned a lot in the process and plan to contribute regularly to Firefox henceforth, it feels really good.
Also thanks to Jason for the detailed description of the fix! :)
Comment 22•4 years ago
|
||
(In reply to Rohit Awate from comment #21)
Hi Jan, thanks for all the help! Really appreciate it.
I learned a lot in the process and plan to contribute regularly to Firefox henceforth, it feels really good.
Also thanks to Jason for the detailed description of the fix! :)
Fantastic! I flagged Jason as reviewer for the patch.
You can 'abandon' (close) the two other Phabricator patches here.
Comment 23•4 years ago
•
|
||
Thanks for helping, Jan.
Thanks for the patch, Rohit. This patch only changes one of the two error messages. I think we should change both.
Now I wonder if we can do even better than V8. "Numeric separator" is pretty jargony; if we say "underscore" it will probably be clearer what the error is about.
for 123_
,
current: "missing digit after '_' numeric separator"
V8: "Numeric separators are not allowed at the end of numeric literals"
is this better?: "number can't end with an underscore"
for 1__234
,
current: "missing digit after '_' numeric separator"
patch: "multiple numeric separators '_' are not allowed"
V8: "Only one underscore is allowed as numeric separator"
is this better?: "number can't contain multiple adjacent underscores"
Assignee | ||
Comment 24•4 years ago
|
||
I guess that does make sense considering the underscore is the only legal numeric separator.
Assignee | ||
Comment 25•4 years ago
|
||
Now that I think about it, "multiple numeric separators '_' are not allowed"
might end up conveying that only one single underscore is allowed in a number literal. That is a bit ridiculous but I feel some people might interpret it as so.
Should I make the changes you proposed?
Comment 26•4 years ago
|
||
Yes, please!
Updated•4 years ago
|
Assignee | ||
Comment 27•4 years ago
|
||
Assignee | ||
Comment 28•4 years ago
|
||
Done! Are the error enum names okay?
This time I used hg commit --amend
and yet moz-phab
created a new revision. I'm confused. What am I doing wrong?
Assignee | ||
Comment 29•4 years ago
|
||
Hi Jason, thanks for accepting my patch! Do I need to add a checkin-needed
tag to the revision on Phabricator?
Updated•4 years ago
|
Comment 30•4 years ago
|
||
(In reply to Rohit Awate from comment #28)
Done! Are the error enum names okay?
This time I usedhg commit --amend
and yetmoz-phab
created a new revision. I'm confused. What am I doing wrong?
The names are fine. I think moz-phab looks for a Differential revision:
line in your commit message. If it's not there, you'll get a new revision.
You can use hg log -v
to see the full commit message (without -v
, it just shows the first line).
I'll land this.
Comment 31•4 years ago
|
||
OK, I didn't land it. I noticed a typo and requested a change.
Assignee | ||
Comment 32•4 years ago
|
||
OK, I didn't land it. I noticed a typo and requested a change.
Shoot! Fixed it.
The names are fine. I think moz-phab looks for a Differential revision: line in your commit message. If it's not there, you'll get a new revision. You can use hg log -v to see the full commit message (without -v, it just shows the first line).
Thanks! This worked.
Comment 33•4 years ago
|
||
Pushed by jorendorff@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/08d0bf739bad Improve numeric separators error messages r=jorendorff
Comment 34•4 years ago
|
||
bugherder |
Updated•4 years ago
|
Comment 35•4 years ago
|
||
Bravo for this change!
Assignee | ||
Comment 36•4 years ago
|
||
(In reply to Sylvestre Ledru [:Sylvestre] from comment #35)
Bravo for this change!
Thanks Sylvestre! I messed up quite a bit; mostly because the contribution process is quite involved. However, I learned a lot and loved the welcoming, helpful and patient community. I hope to contribute regularly to Firefox henceforth. Also, I plan on blogging about this soon, so that new contributors won't repeat the same mistakes I made! ;)
Once again, thanks to Jason, Jan and Sonia! :)
Description
•