summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2019-03-08 18:46:02 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2019-03-08 18:46:02 +0100
commit40fa34979a4f4fd056bc05f8af0cb7b511205c11 (patch)
treeed8bc7792b686887800dd51e4f4e8b719ba05bb7
parentd3770a01f0a0648cc51baa350eb80c88588bf542 (diff)
downloadvala-40fa34979a4f4fd056bc05f8af0cb7b511205c11.tar.gz
parser: Restrict source_reference for catch/lock expression to its header
-rw-r--r--vala/valaparser.vala9
1 files changed, 6 insertions, 3 deletions
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 032e2638b..236ab4947 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -2096,8 +2096,9 @@ public class Vala.Parser : CodeVisitor {
}
void parse_catch_clauses (List<CatchClause> catch_clauses) throws ParseError {
- while (accept (TokenType.CATCH)) {
+ while (current () == TokenType.CATCH) {
var begin = get_location ();
+ expect (TokenType.CATCH);
DataType type = null;
string id = null;
if (accept (TokenType.OPEN_PARENS)) {
@@ -2105,8 +2106,9 @@ public class Vala.Parser : CodeVisitor {
id = parse_identifier ();
expect (TokenType.CLOSE_PARENS);
}
+ var src = get_src (begin);
var block = parse_block ();
- catch_clauses.add (new CatchClause (type, id, block, get_src (begin)));
+ catch_clauses.add (new CatchClause (type, id, block, src));
}
}
@@ -2122,11 +2124,12 @@ public class Vala.Parser : CodeVisitor {
expect (TokenType.OPEN_PARENS);
var expr = parse_expression ();
expect (TokenType.CLOSE_PARENS);
+ var src = get_src (begin);
Block? stmt = null;
if (current () != TokenType.SEMICOLON) {
stmt = parse_embedded_statement ("lock", false);
}
- return new LockStatement (expr, stmt, get_src (begin));
+ return new LockStatement (expr, stmt, src);
}
Statement parse_unlock_statement () throws ParseError {