Commit a78afd0e authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter
Browse files

improve error reporting for expression, while, and for statements and for

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
parent e8588de2
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
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment