From: Juerg Billeter Date: Fri, 31 Aug 2007 21:23:58 +0000 (+0000) Subject: improve error reporting for expression, while, and for statements and for X-Git-Tag: VALA_0_1_4~89 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a78afd0ee3ca4c1a57bfb7d4162f1cc146c9613e;p=thirdparty%2Fvala.git improve error reporting for expression, while, and for statements and for 2007-08-31 Juerg Billeter * vala/valasemanticanalyzer.vala: improve error reporting for expression, while, and for statements and for parenthesized expressions svn path=/trunk/; revision=559 --- diff --git a/ChangeLog b/ChangeLog index 0429dee92..2f6fe9988 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-08-31 Jürg Billeter + + * vala/valasemanticanalyzer.vala: improve error reporting for + expression, while, and for statements and for parenthesized + expressions + 2007-08-31 Jürg Billeter * configure.ac: Post-release version bump diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala index ce06d210f..b498346c0 100644 --- a/vala/valasemanticanalyzer.vala +++ b/vala/valasemanticanalyzer.vala @@ -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;