[vala] Improve error message for declaration in embedded statement
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Improve error message for declaration in embedded statement
- Date: Sat, 16 Oct 2010 14:03:50 +0000 (UTC)
commit 85af585a0c2f9a7fc7ff326f1879784acac697cc
Author: Jürg Billeter <j bitron ch>
Date: Sat Oct 16 16:02:04 2010 +0200
Improve error message for declaration in embedded statement
Fixes bug 615230.
vala/valaparser.vala | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 43dd8e0..e73ca75 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -1628,7 +1628,23 @@ public class Vala.Parser : CodeVisitor {
case TokenType.TRY: return parse_try_statement ();
case TokenType.LOCK: return parse_lock_statement ();
case TokenType.DELETE: return parse_delete_statement ();
- default: return parse_expression_statement ();
+ case TokenType.VAR:
+ case TokenType.CONST:
+ throw new ParseError.SYNTAX (get_error ("embedded statement cannot be declaration "));
+ case TokenType.OP_INC:
+ case TokenType.OP_DEC:
+ case TokenType.BASE:
+ case TokenType.THIS:
+ case TokenType.OPEN_PARENS:
+ case TokenType.STAR:
+ case TokenType.NEW:
+ return parse_expression_statement ();
+ default:
+ if (is_expression ()) {
+ return parse_expression_statement ();
+ } else {
+ throw new ParseError.SYNTAX (get_error ("embedded statement cannot be declaration"));
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]