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 0429dee..2f6fe99 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 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
 
 2007-08-31  Jürg Billeter  <j@bitron.ch>
index ce06d21..b498346 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;