]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Report error on use of tuples
authorJürg Billeter <j@bitron.ch>
Sat, 13 Mar 2010 16:32:48 +0000 (17:32 +0100)
committerJürg Billeter <j@bitron.ch>
Sat, 13 Mar 2010 16:33:54 +0000 (17:33 +0100)
Tuples are not supported as primary expressions.

Based on patch by Adam Folmert, fixes bug 597955.

vala/valaparser.vala
vala/valatuple.vala

index b3d3454c57588eba6c91979424b65c410503cd6c..d0649cd66774bb1dc91d06db29412b4a60606fbf 100644 (file)
@@ -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);
                        }
index 0efab3e466b75d3d76f2c847142b819826652f87..b723d391de8e285e97b79eb58c56cd79bb875a22 100644 (file)
@@ -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;
+       }
 }