+2008-12-01 Jürg Billeter <j@bitron.ch>
+
+ * vala/valabinaryexpression.vala:
+ * vala/valaconditionalexpression.vala:
+
+ Fix critical when using conditional expressions in method contracts
+
2008-12-01 Jürg Billeter <j@bitron.ch>
* gobject/valagobjectmodule.vala:
checked = true;
- if (operator == BinaryOperator.AND || operator == BinaryOperator.OR) {
+ // some expressions are not in a block,
+ // for example, expressions in method contracts
+ if (analyzer.current_symbol is Block
+ && (operator == BinaryOperator.AND || operator == BinaryOperator.OR)) {
var old_insert_block = analyzer.insert_block;
analyzer.insert_block = prepare_condition_split (analyzer);
// integer type or flags type
value_type = left.value_type;
+ } else if (operator == BinaryOperator.AND
+ || operator == BinaryOperator.OR) {
+ if (!left.value_type.compatible (analyzer.bool_type) || !right.value_type.compatible (analyzer.bool_type)) {
+ error = true;
+ Report.error (source_reference, "Operands must be boolean");
+ }
+
+ value_type = analyzer.bool_type;
} else if (operator == BinaryOperator.IN) {
if (left.value_type.compatible (analyzer.int_type)
&& right.value_type.compatible (analyzer.int_type)) {
checked = true;
+ if (!(analyzer.current_symbol is Block)) {
+ Report.error (source_reference, "Conditional expressions may only be used in blocks");
+ error = true;
+ return false;
+ }
+
var old_insert_block = analyzer.insert_block;
analyzer.insert_block = prepare_condition_split (analyzer);