Skip to content

Fix 8262: allow unparenthesized parameter in async arrow-function#8444

Merged
yuit merged 6 commits into
masterfrom
fix8262
May 5, 2016
Merged

Fix 8262: allow unparenthesized parameter in async arrow-function#8444
yuit merged 6 commits into
masterfrom
fix8262

Conversation

@yuit
Copy link
Copy Markdown
Contributor

@yuit yuit commented May 3, 2016

Fix #8262

Comment thread src/compiler/parser.ts Outdated
// From ES6 spec:
// AsyncArrowFunction[In, Yield, Await]::
// async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In]
const unParenthesizedAsyncArrowFunction = tryParseUnParenthesizedAsyncArrowFunctionExpressionWorker();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

help! it's the MicroSoft BiCapitalisation DisEase!
should be unparenthensizedAsyncArrowFunction and tryParseUnparenthesizedAsyncArrowFunctionExpressionWorker :)

Comment thread src/compiler/parser.ts Outdated
}

// From ES6 spec:
// AsyncArrowFunction[In, Yield, Await]::
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this presented in the spec? I feel like it should be integrated into the grammar production list (1,2,3,4,5) above, as well as in the code. For example, it could be

const arrowExpression = tryParseParen... || tryParseUnparen ...;
if (arrowExpression) { return arrowExpression; }

Copy link
Copy Markdown
Contributor Author

@yuit yuit May 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good point. the comment is what it is in the spec. It is the upcomment spec for async await

Comment thread src/compiler/parser.ts Outdated
// Production (1) of AsyncArrowFunctionExpression is parsed in "tryParseAsyncSimpleArrowFunctionExpression".
// And production (2) is parsed in "tryParseParenthesizedArrowFunctionExpression".
//
// If we do successfully parse arrow-function, we must * not * recurse for productions 1, 2 or 3. An ArrowFunction is
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: no spaces around the stars in not

@sandersn
Copy link
Copy Markdown
Member

sandersn commented May 4, 2016

👍 with a couple of minor suggestions

@yuit yuit merged commit 7521891 into master May 5, 2016
@yuit yuit deleted the fix8262 branch May 5, 2016 00:00
Comment thread src/compiler/parser.ts
}

function tryParseAsyncSimpleArrowFunctionExpression(): ArrowFunction {
const isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you check first that token === SyntaxKind.AsyncKeyword before calling the function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I just realize I should do that since lookAhead can be expensive

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants