From: Jürg Billeter Date: Sat, 13 Mar 2010 16:32:48 +0000 (+0100) Subject: Report error on use of tuples X-Git-Tag: 0.8.0~207 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c5ea5f55ab483330858a2d374ff13e7f45d9a2b8;p=thirdparty%2Fvala.git Report error on use of tuples Tuples are not supported as primary expressions. Based on patch by Adam Folmert, fixes bug 597955. --- diff --git a/vala/valaparser.vala b/vala/valaparser.vala index b3d3454c5..d0649cd66 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 (); 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 0efab3e46..b723d391d 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_list = new ArrayList (); - 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; + } }