vala r1526 - in trunk: . vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1526 - in trunk: . vala
- Date: Sun, 1 Jun 2008 11:31:44 +0000 (UTC)
Author: juergbi
Date: Sun Jun 1 11:31:44 2008
New Revision: 1526
URL: http://svn.gnome.org/viewvc/vala?rev=1526&view=rev
Log:
2008-06-01 JÃrg Billeter <j bitron ch>
* vala/valasemanticanalyzer.vala:
Report error when trying to use unowned variables as argument
for owned reference and output parameters
Modified:
trunk/ChangeLog
trunk/vala/valasemanticanalyzer.vala
Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala (original)
+++ trunk/vala/valasemanticanalyzer.vala Sun Jun 1 11:31:44 2008
@@ -2042,12 +2042,32 @@
Report.error (arg.source_reference, "Argument %d: Cannot pass ref argument to non-reference parameter".printf (i + 1));
return false;
}
+
+ // weak variables can only be used with weak ref parameters
+ if (param.parameter_type.is_disposable ()) {
+ if (!(arg.value_type is PointerType) && !arg.value_type.value_owned) {
+ /* variable doesn't own the value */
+ expr.error = true;
+ Report.error (arg.source_reference, "Invalid assignment from owned expression to unowned variable");
+ return false;
+ }
+ }
} else if (arg_type == 3) {
if (param.direction != ParameterDirection.OUT) {
expr.error = true;
Report.error (arg.source_reference, "Argument %d: Cannot pass out argument to non-output parameter".printf (i + 1));
return false;
}
+
+ // weak variables can only be used with weak out parameters
+ if (param.parameter_type.is_disposable ()) {
+ if (!(arg.value_type is PointerType) && !arg.value_type.value_owned) {
+ /* variable doesn't own the value */
+ expr.error = true;
+ Report.error (arg.source_reference, "Invalid assignment from owned expression to unowned variable");
+ return false;
+ }
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]