Arrow function parameter default expressions should not permit await keyword
Created attachment 378411 [details] Patch
Comment on attachment 378411 [details] Patch Ugh, guess this solution is too naive since it breaks, e.g., `await => {}` at the top level (which evidently neither we nor test262 have tests for...). Also the problem description is a bit off. We need to prohibit await in default expressions of: - async arrow and non-arrow functions - non-async arrow functions in an async context So these need to become errors: async function f(x = await => {}) {} async (x = await => {}) => {}; async function f() { (x = await => {}) => {}; } async () => { (x = await => {}) => {}; }; And these must not become errors: async function f() { function g(x = await => {}) {} } (x = await => {}) => {};
Created attachment 378591 [details] Patch
Comment on attachment 378591 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=378591&action=review > Source/JavaScriptCore/parser/Parser.cpp:350 > + semanticFailIfTrue(!m_parserState.allowAwait && match(AWAIT), "Cannot use 'await' as a parameter name in an async function"); What is the difference between this check and isDisallowedIdentifierAwait?
(In reply to Yusuke Suzuki from comment #4) > Comment on attachment 378591 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=378591&action=review > > > Source/JavaScriptCore/parser/Parser.cpp:350 > > + semanticFailIfTrue(!m_parserState.allowAwait && match(AWAIT), "Cannot use 'await' as a parameter name in an async function"); > > What is the difference between this check and isDisallowedIdentifierAwait? Hmm, I (In reply to Yusuke Suzuki from comment #4) > Comment on attachment 378591 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=378591&action=review > > > Source/JavaScriptCore/parser/Parser.cpp:350 > > + semanticFailIfTrue(!m_parserState.allowAwait && match(AWAIT), "Cannot use 'await' as a parameter name in an async function"); > > What is the difference between this check and isDisallowedIdentifierAwait? Hmm, I didn't consciously avoid `isDisallowedIdentifierAwait` here, but the observable difference I can see would be in module code: namely, that `await => 3` in a module would change from `Cannot use 'await' as a parameter name in a module.` to `Cannot use 'await' as a parameter name in an async function.`, which would be incorrect.
Created attachment 378883 [details] Patch
Comment on attachment 378883 [details] Patch Added even more tests (for all the things I was implicitly expecting). Any further concerns here?
Created attachment 378887 [details] Patch
Created attachment 378888 [details] Patch
Comment on attachment 378888 [details] Patch Clearing flags on attachment: 378888 Committed r249925: <https://trac.webkit.org/changeset/249925>
All reviewed patches have been landed. Closing bug.
<rdar://problem/55418472>