[vala] Report error on use of tuples
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Report error on use of tuples
- Date: Sat, 13 Mar 2010 16:34:56 +0000 (UTC)
commit c5ea5f55ab483330858a2d374ff13e7f45d9a2b8
Author: Jürg Billeter <j bitron ch>
Date: Sat Mar 13 17:32:48 2010 +0100
Report error on use of tuples
Tuples are not supported as primary expressions.
Based on patch by Adam Folmert, fixes bug 597955.
vala/valaparser.vala | 6 ++++--
vala/valatuple.vala | 17 +++++++++++++++--
2 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index b3d3454..d0649cd 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -1,6 +1,6 @@
/* valaparser.vala
*
- * Copyright (C) 2006-2009 Jürg Billeter
+ * Copyright (C) 2006-2010 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -632,6 +632,8 @@ public class Vala.Parser : CodeVisitor {
}
Expression parse_tuple () throws ParseError {
+ var begin = get_location ();
+
expect (TokenType.OPEN_PARENS);
var expr_list = new ArrayList<Expression> ();
if (current () != TokenType.CLOSE_PARENS) {
@@ -641,7 +643,7 @@ public class Vala.Parser : CodeVisitor {
}
expect (TokenType.CLOSE_PARENS);
if (expr_list.size != 1) {
- var tuple = new Tuple ();
+ var tuple = new Tuple (get_src (begin));
foreach (Expression expr in expr_list) {
tuple.add_expression (expr);
}
diff --git a/vala/valatuple.vala b/vala/valatuple.vala
index 0efab3e..b723d39 100644
--- a/vala/valatuple.vala
+++ b/vala/valatuple.vala
@@ -1,6 +1,6 @@
/* valatuple.vala
*
- * Copyright (C) 2006-2008 Jürg Billeter
+ * Copyright (C) 2006-2010 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -28,7 +28,8 @@ using GLib;
public class Vala.Tuple : Expression {
private List<Expression> expression_list = new ArrayList<Expression> ();
- public Tuple () {
+ public Tuple (SourceReference? source_reference = null) {
+ this.source_reference = source_reference;
}
public void add_expression (Expression expr) {
@@ -42,5 +43,17 @@ public class Vala.Tuple : Expression {
public override bool is_pure () {
return false;
}
+
+ public override bool check (SemanticAnalyzer analyzer) {
+ if (checked) {
+ return !error;
+ }
+
+ checked = true;
+
+ Report.error (source_reference, "tuples are not supported");
+ error = true;
+ return false;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]