vala r1528 - in trunk: . vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1528 - in trunk: . vala
- Date: Sun, 1 Jun 2008 14:01:34 +0000 (UTC)
Author: juergbi
Date: Sun Jun 1 14:01:33 2008
New Revision: 1528
URL: http://svn.gnome.org/viewvc/vala?rev=1528&view=rev
Log:
2008-06-01 JÃrg Billeter <j bitron ch>
* vala/valasemanticanalyzer.vala:
Report error when trying to use unowned element variable in
foreach statement using iterators
Modified:
trunk/ChangeLog
trunk/vala/valasemanticanalyzer.vala
Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala (original)
+++ trunk/vala/valasemanticanalyzer.vala Sun Jun 1 14:01:33 2008
@@ -1025,7 +1025,8 @@
stmt.collection.target_type = collection_type.copy ();
DataType element_data_type = null;
-
+ bool element_owned = false;
+
if (collection_type.is_array ()) {
var array_type = (ArrayType) collection_type;
element_data_type = array_type.element_type;
@@ -1034,6 +1035,8 @@
element_data_type = (DataType) collection_type.get_type_arguments ().get (0);
}
} else if (iterable_type != null && collection_type.compatible (iterable_type)) {
+ element_owned = true;
+
if (list_type == null || !collection_type.compatible (new ObjectType (list_type))) {
// don't use iterator objects for lists for performance reasons
var foreach_iterator_type = new ObjectType (iterator_type);
@@ -1074,6 +1077,10 @@
stmt.error = true;
Report.error (stmt.source_reference, "Foreach: Cannot convert from `%s' to `%s'".printf (element_data_type.to_string (), stmt.type_reference.to_string ()));
return;
+ } else if (element_data_type.is_disposable () && element_owned && !stmt.type_reference.value_owned) {
+ stmt.error = true;
+ Report.error (stmt.source_reference, "Foreach: Invalid assignment from owned expression to unowned variable");
+ return;
}
current_source_file.add_type_dependency (stmt.type_reference, SourceFileDependencyType.SOURCE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]