diff --git a/shared/cplusplus/AST.cpp b/shared/cplusplus/AST.cpp
index 911af02e53cc312dc5520f3d3080273fdaa2f65e..ff19e4439b80021700897d16f97fd6532c338b8b 100644
--- a/shared/cplusplus/AST.cpp
+++ b/shared/cplusplus/AST.cpp
@@ -2796,10 +2796,15 @@ unsigned WhileStatementAST::firstToken() const
 
 unsigned WhileStatementAST::lastToken() const
 {
-    assert(0 && "review me");
     if (statement)
         return statement->lastToken();
-    return rparen_token + 1;
+    else if (rparen_token)
+        return rparen_token + 1;
+    else if (condition)
+        return condition->lastToken();
+    else if (lparen_token)
+        return lparen_token + 1;
+    return while_token + 1;
 }
 
 CPLUSPLUS_END_NAMESPACE