From: Jürg Billeter Date: Mon, 30 Apr 2007 07:59:19 +0000 (+0000) Subject: fix type check in relational operations, fixes bug 434507 X-Git-Tag: VALA_0_0_9~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5bc3d7dec7adb60507f7ed7fd5d9a1b942f52383;p=platform%2Fupstream%2Fvala.git fix type check in relational operations, fixes bug 434507 2007-04-30 Jürg Billeter * vala/valasemanticanalyzer.vala: fix type check in relational operations, fixes bug 434507 svn path=/trunk/; revision=290 --- diff --git a/vala/ChangeLog b/vala/ChangeLog index f66389d..76d2025 100644 --- a/vala/ChangeLog +++ b/vala/ChangeLog @@ -1,5 +1,10 @@ 2007-04-30 Jürg Billeter + * vala/valasemanticanalyzer.vala: fix type check in relational + operations, fixes bug 434507 + +2007-04-30 Jürg Billeter + * vala/valacodegenerator.vala: add pointer to integer conversion in foreach statements, fixes bug 433288 diff --git a/vala/vala/valasemanticanalyzer.vala b/vala/vala/valasemanticanalyzer.vala index e169989..c9dcc7a 100644 --- a/vala/vala/valasemanticanalyzer.vala +++ b/vala/vala/valasemanticanalyzer.vala @@ -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; } }