[vala] Check type of default arguments



commit ddfac77ab73e8a1d10070f08fa2120b5cf3713bb
Author: Florian Brosch <flo brosch gmail com>
Date:   Tue Jan 24 21:14:35 2012 +0100

    Check type of default arguments

 vala/valaparameter.vala |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/vala/valaparameter.vala b/vala/valaparameter.vala
index e34b773..22fe0c8 100644
--- a/vala/valaparameter.vala
+++ b/vala/valaparameter.vala
@@ -154,6 +154,8 @@ public class Vala.Parameter : Variable {
 				Report.warning (source_reference, "`null' incompatible with parameter type `%s`".printf (variable_type.to_string ()));
 			} else if (!(initializer is NullLiteral) && direction == ParameterDirection.OUT) {
 				Report.error (source_reference, "only `null' is allowed as default value for out parameters");
+			} else if (direction == ParameterDirection.IN && !initializer.value_type.compatible (variable_type)) {
+				Report.error (initializer.source_reference, "Cannot convert from `%s' to `%s'".printf (initializer.value_type.to_string (), variable_type.to_string ()));
 			} else if (direction == ParameterDirection.REF) {
 				Report.error (source_reference, "default value not allowed for ref parameter");
 			}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]