enums/in-invalid.test \
enums/no_gtype_to_string.vala \
enums/switch.vala \
+ enums/unsafe-assignment.vala \
enums/bug614424.vala \
enums/bug666035.vala \
enums/bug666035-1.test \
--- /dev/null
+enum Foo {
+ BAR
+}
+
+void main () {
+ {
+ Foo foo = 23;
+ }
+ {
+ Foo foo = Foo.BAR;
+ foo = 42;
+ }
+}
error = true;
Report.error (source_reference, "Assignment: Cannot convert from `%s' to `%s'", right.value_type.to_string (), left.value_type.to_string ());
return false;
+ } else if (left.value_type is EnumValueType && right.value_type is IntegerType
+ && (!(right is IntegerLiteral) || ((IntegerLiteral) right).value != "0")) {
+ //FIXME This will have to be an error in the future?
+ Report.notice (source_reference, "Assignment: Unsafe conversion from `%s' to `%s'", right.value_type.to_string (), left.value_type.to_string ());
}
if (!(ma.symbol_reference is Property)) {
if (type_symbol is Enum && target_type.type_symbol is Struct && ((Struct) target_type.type_symbol).is_integer_type ()) {
return true;
+ } else if (target_type.type_symbol is Enum && type_symbol is Struct && ((Struct) type_symbol).is_integer_type ()) {
+ //FIXME Drop this unsafe direction in the future?
+ return true;
}
// check for matching ownership of type-arguments
error = true;
Report.error (source_reference, "Assignment: Cannot convert from `%s' to `%s'", initializer.value_type.to_string (), variable_type.to_string ());
return false;
+ } else if (variable_type is EnumValueType && initializer.value_type is IntegerType
+ && (!(initializer is IntegerLiteral) || ((IntegerLiteral) initializer).value != "0")) {
+ //FIXME This will have to be an error in the future?
+ Report.notice (source_reference, "Assignment: Unsafe conversion from `%s' to `%s'", initializer.value_type.to_string (), variable_type.to_string ());
}
if (variable_array_type != null && variable_array_type.inline_allocated && !variable_array_type.fixed_length && is_initializer_list) {