Closed Bug 1478911 Opened 6 years ago Closed 6 years ago

Improve the error message when yield/await is used inside parameter

Categories

(Core :: JavaScript Engine, enhancement, P5)

enhancement

Tracking

()

RESOLVED FIXED
mozilla64
Tracking Status
firefox64 --- fixed

People

(Reporter: arai, Assigned: Anushi1998, Mentored)

References

(Blocks 1 open bug)

Details

(Keywords: good-first-bug, Whiteboard: [lang=c++])

Attachments

(1 file, 2 obsolete files)

js> async function* f(a = yield) {} typein:19:22 SyntaxError: yield in default expression: typein:19:22 async function* f(a = yield) {} typein:19:22 ......................^ js> async function* f(a = await 10) {} typein:21:22 SyntaxError: await can't be used in default expression: typein:21:22 async function* f(a = await 10) {} typein:21:22 ......................^ js> async function* f([a = yield]) {} typein:24:23 SyntaxError: yield in default expression: typein:24:23 async function* f([a = yield]) {} typein:24:23 .......................^ js> async function* f([a = await]) {} typein:23:28 SyntaxError: expected expression, got ']': typein:23:28 async function* f([a = await]) {} typein:23:28 ............................^ the actual issue is that yield/await cannot be used in parameter, and it's not about whether it's in default expression. (of course it can appear only in default parameter or destructuring default tho) we should say something like: * yield expression can't be used in parameter * await expression can't be used in parameter other browsers's output: Safari > function* f(a = yield) {} SyntaxError: Unexpected keyword 'yield'. Cannot use yield expression within parameters. > async function f(a = await 10) {} SyntaxError: Unexpected identifier 'await'. Cannot use await expression within parameters. Chrome > function* f(a = yield) {} Uncaught SyntaxError: Yield expression not allowed in formal parameter > async function f(a = await 10) {} Uncaught SyntaxError: Illegal await-expression in formal parameters of async function things to do here: 1. fix the error message in js/src/js.msg 2. fix the name of the error message in js/src/js.msg, and its consumers
Priority: -- → P5
I want to solve this issue.
Thanks! Let me know if you have any question. here's instruction for preparing development environment and building Firefox. https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Build_Instructions/Simple_Firefox_build also you can look for the error message consumer here https://searchfox.org/ Once you've fixed it locally, please export it as a patch file and attach here, and ask review from me.
Can I work on this bug?
Flags: needinfo?(arai.unmht)
mayank is working on this bug (see comment #1). there are similar bugs under bug 622261, let me know if you need help finding a bug to work on (bug comment or :arai in #jsapi channel in irc)
Flags: needinfo?(arai.unmht)
Can somebody give me some pointers on where to start and also which file should I be looking at to fix this bug?
Can i go ahead for this bug
i solved it please ,if mayank hasn't done it i can post it in :)
sure, given that there's no activity for a while, you can take this over.
sorry i forgot to introduce myself ; i am an undergrad in engineering and looking up for open source contribution ,setting goals for getting chance to be a part of gsoc and mozilla ; i have a problem i changed file in my build (files) but now how to i submit it ,please help :)
basic workflow: 1. clone mozilla-unified (or mozilla-central) 2. modify file 3. create a changeset for the modification by "hg commit" command a. the commit message should follow this rule https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Committing_Rules_and_Responsibilities#Checkin_comment 4. export the changeset by "hg export -r . > somewhere/bugNNNN.patch" 5. attach the file here, and ask review (there's review field in the attachment form) if you've done 1-2, please try 3-5.
:arai, Is anybody working on this bug?
Flags: needinfo?(arai.unmht)
I'm not sure who's currently working on, but I'll assign this bug to anyone who posts the patch ;)
Flags: needinfo?(arai.unmht)
Is anyone working on this? I am new to opensource and i want take this up.
Yes I have completed it and will be submitting PR soon :)
Attached patch bug1478911.patch (obsolete) — Splinter Review
Attachment #9007408 - Flags: review?(arai.unmht)
Assignee: nobody → anushimaheshwari95
Status: NEW → ASSIGNED
Comment on attachment 9007408 [details] [diff] [review] bug1478911.patch Review of attachment 9007408 [details] [diff] [review]: ----------------------------------------------------------------- Thank you for your patch :D given the expected error message is changed, can you fix the following line as well? https://searchfox.org/mozilla-central/rev/37663bb87004167184de6f2afa6b05875eb0528e/js/src/tests/non262/async-functions/await-in-parameters-of-async-func.js#23 this is just a message and this test doesn't fail, but nice to fix :) Also, please change the first line of the commit message to follow this rule? https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Committing_Rules_and_Responsibilities#Commit_message_restrictions basically, "Bug NNNNNN - description of the change" ::: js/src/js.msg @@ +188,4 @@ > MSG_DEF(JSMSG_ARRAY_INIT_TOO_BIG, 0, JSEXN_INTERNALERR, "array initializer too large") > MSG_DEF(JSMSG_AS_AFTER_IMPORT_STAR, 0, JSEXN_SYNTAXERR, "missing keyword 'as' after import *") > MSG_DEF(JSMSG_AS_AFTER_RESERVED_WORD, 1, JSEXN_SYNTAXERR, "missing keyword 'as' after reserved word '{0}'") > +MSG_DEF(JSMSG_AWAIT_IN_PARAMETER, 0, JSEXN_SYNTAXERR, "await expression can't be used in parameter") please align "0" to "1" in the previous line
Attachment #9007408 - Flags: review?(arai.unmht) → feedback+
Attached patch bug1478911.patch (obsolete) — Splinter Review
Attachment #9007410 - Flags: review?(arai.unmht)
Comment on attachment 9007410 [details] [diff] [review] bug1478911.patch Review of attachment 9007410 [details] [diff] [review]: ----------------------------------------------------------------- Excellent :D here's try run, which executes automated tests (with previous patch, but the result should be same) https://treeherder.mozilla.org/#/jobs?repo=try&revision=3a8b7bed8badb07801940dd105b903eba2d2864c&group_state=expanded if it completes without any failure, you can add "checkin-needed" keyword to this bug, so that this patch will be landed shortly. also, you can mark the previous patch "obsolete" when attaching new patch. now you can mark it obsolete in attachment details page above.
Attachment #9007410 - Flags: review?(arai.unmht) → review+
Attachment #9007408 - Attachment is obsolete: true
Thanks :arai :)
I overlooked that the bug number in the commit message is wrong. can you fix it to "Bug 1478911" ?
Flags: needinfo?(anushimaheshwari95)
also, when attaching, you can add "r=arai" at the end of the commit message, first line, and choose "+" for "review" (please declare that you're carrying forward the previous review, in the comment) the try run looks fine. after attaching the updated patch, you can add "checkin-needed" keyword.
Attached patch bug1478911.patchSplinter Review
Carrying forward previous review.
Flags: needinfo?(anushimaheshwari95)
Attachment #9007419 - Flags: review+
Attachment #9007419 - Flags: checkin+
not, "checkin" flag. add "checkin-needed" to "Keyword" under "Tracking" section
Attachment #9007419 - Flags: checkin+
Keywords: checkin-needed
Attachment #9007410 - Attachment is obsolete: true
Pushed by toros@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/5208ae2ec7da Changed error message and name of error for `JSMSG_AWAIT_IN_DEFAULT` and `JSMSG_YIELD_IN_PARAMETER` and corresponding change in consumer files. r=arai
Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: