[vala/staging] parser: Handle incomplete expression statements
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] parser: Handle incomplete expression statements
- Date: Sat, 11 Apr 2020 14:04:59 +0000 (UTC)
commit 4368a4fa667148378dcdbd251a4ae4e00c9a8e5a
Author: Princeton Ferro <princetonferro gmail com>
Date: Thu Apr 9 21:15:45 2020 +0200
parser: Handle incomplete expression statements
Incomplete expression statements are parsed as expression statements
now, rather than local variable declarations. This primarily affects
incomplete member access expressions at the end of blocks.
vala/valaparser.vala | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 48818a293..e61372975 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -1665,7 +1665,19 @@ public class Vala.Parser : CodeVisitor {
var begin = get_location ();
// decide between declaration and expression statement
- skip_type ();
+ try {
+ skip_type ();
+ } catch (ParseError e) {
+ prev ();
+ var token = current ();
+ next ();
+ if (token == TokenType.DOT || token == TokenType.DOUBLE_COLON) {
+ rollback (begin);
+ return true;
+ } else {
+ throw e;
+ }
+ }
switch (current ()) {
// invocation expression
case TokenType.OPEN_PARENS:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]