]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
improve error reporting for expression, while, and for statements and for
authorJuerg Billeter <j@bitron.ch>
Fri, 31 Aug 2007 21:23:58 +0000 (21:23 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Fri, 31 Aug 2007 21:23:58 +0000 (21:23 +0000)
2007-08-31  Juerg Billeter  <j@bitron.ch>

* vala/valasemanticanalyzer.vala: improve error reporting for
  expression, while, and for statements and for parenthesized
  expressions

svn path=/trunk/; revision=559

ChangeLog
vala/valasemanticanalyzer.vala

index 0429dee92ecbb3a04d3b9bb70f9910200709a143..2f6fe998856579a82ce65a360e52602708b03298 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-08-31  Jürg Billeter  <j@bitron.ch>
+
+       * vala/valasemanticanalyzer.vala: improve error reporting for
+         expression, while, and for statements and for parenthesized
+         expressions
+
 2007-08-31  Jürg Billeter  <j@bitron.ch>
 
        * configure.ac: Post-release version bump
index ce06d210fd9261c30a834ebb81983609cab3da2d..b498346c000e16a82066ba5013bf50ee91811df4 100644 (file)
@@ -800,6 +800,12 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
        }
 
        public override void visit_expression_statement (ExpressionStatement! stmt) {
+               if (stmt.expression.error) {
+                       // ignore inner error
+                       stmt.error = true;
+                       return;
+               }
+
                if (stmt.expression.static_type != null &&
                    stmt.expression.static_type.transfers_ownership) {
                        Report.warning (stmt.source_reference, "Short-living reference");
@@ -823,6 +829,12 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
        }
 
        public override void visit_while_statement (WhileStatement! stmt) {
+               if (stmt.condition.error) {
+                       /* if there was an error in the condition, skip this check */
+                       stmt.error = true;
+                       return;
+               }
+
                if (stmt.condition.static_type.data_type != bool_type.data_type) {
                        stmt.error = true;
                        Report.error (stmt.condition.source_reference, "Condition must be boolean");
@@ -831,6 +843,12 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
        }
 
        public override void visit_for_statement (ForStatement! stmt) {
+               if (stmt.condition.error) {
+                       /* if there was an error in the condition, skip this check */
+                       stmt.error = true;
+                       return;
+               }
+
                if (stmt.condition.static_type.data_type != bool_type.data_type) {
                        stmt.error = true;
                        Report.error (stmt.condition.source_reference, "Condition must be boolean");
@@ -1203,6 +1221,13 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                        return;
                }
 
+               if (expr.inner.static_type == null) {
+                       // static type may be null for method references
+                       expr.error = true;
+                       Report.error (expr.inner.source_reference, "Invalid expression type");
+                       return;
+               }
+
                expr.static_type = expr.inner.static_type.copy ();
                // don't call g_object_ref_sink on inner and outer expression
                expr.static_type.floating_reference = false;