Permalink
Browse files

Fixed parser error when 'await' is used as statement expression.

  • Loading branch information...
1 parent 520c648 commit a7958379eeb0500015cf4788c8985bdb2778a0df @dgrunwald dgrunwald committed Mar 8, 2012
@@ -469,7 +469,7 @@ bool SkipQuestionMark(ref Token pt)
/* True, if lookahead is a primitive type keyword, or */
/* if it is a type declaration followed by an ident */
bool IsLocalVarDecl () {
- if (IsYieldStatement()) {
+ if (IsYieldStatement() || la.kind == Tokens.Await) {
return false;
}
if ((Tokens.TypeKW[la.kind] && Peek(1).kind != Tokens.Dot) || la.kind == Tokens.Void) {
@@ -109,6 +109,23 @@ public void NestedAwait()
Assert.AreEqual(UnaryOperatorType.Await, nested.Op);
Assert.IsTrue(nested.Expression is IdentifierExpression);
}
+
+ [Test]
+ public void AwaitStaticMethodCall()
+ {
+ var uoe = ParseUtilCSharp.ParseExpression<UnaryOperatorExpression>("await Task.WhenAll(a, b)");
+ Assert.AreEqual(UnaryOperatorType.Await, uoe.Op);
+ Assert.IsTrue(uoe.Expression is InvocationExpression);
+ }
+
+ [Test]
+ public void AwaitStaticMethodCallStatement()
+ {
+ var es = ParseUtilCSharp.ParseStatement<ExpressionStatement>("await Task.WhenAll(a, b);");
+ UnaryOperatorExpression uoe = (UnaryOperatorExpression)es.Expression;
+ Assert.AreEqual(UnaryOperatorType.Await, uoe.Op);
+ Assert.IsTrue(uoe.Expression is InvocationExpression);
+ }
#endregion
#region VB.NET

0 comments on commit a795837

Please sign in to comment.