Commit 5bc3d7de authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

fix type check in relational operations, fixes bug 434507

2007-04-30  Jürg Billeter  <j@bitron.ch>

	* vala/valasemanticanalyzer.vala: fix type check in relational
	  operations, fixes bug 434507

svn path=/trunk/; revision=290
parent b745d1f5
2007-04-30 Jürg Billeter <j@bitron.ch>
* vala/valasemanticanalyzer.vala: fix type check in relational
operations, fixes bug 434507
2007-04-30 Jürg Billeter <j@bitron.ch>
* vala/valacodegenerator.vala: add pointer to integer conversion in
......
......@@ -1707,15 +1707,6 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
expr.static_type.takes_ownership = false;
}
private bool check_binary_type (BinaryExpression! expr, string! operation) {
if (!is_type_compatible (expr.right.static_type, expr.left.static_type)) {
Report.error (expr.source_reference, "%s: Cannot convert from `%s' to `%s'".printf (operation, expr.right.static_type.to_string (), expr.left.static_type.to_string ()));
return false;
}
return true;
}
private ref TypeReference get_arithmetic_result_type (TypeReference! left_type, TypeReference! right_type) {
if (!(left_type.data_type is Struct) || !(right_type.data_type is Struct)) {
// at least one operand not struct
......@@ -1809,10 +1800,11 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
expr.left.accept (this);
} else {
/* TODO: check for integer or floating point type in expr.left */
var resulting_type = get_arithmetic_result_type (expr.left.static_type, expr.right.static_type);
if (!check_binary_type (expr, "Relational operation")) {
if (resulting_type == null) {
expr.error = true;
Report.error (expr.source_reference, "Relational operation not supported for types `%s' and `%s'".printf (expr.left.static_type.to_string (), expr.right.static_type.to_string ()));
return;
}
}
......
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