]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Check type of default arguments
authorFlorian Brosch <flo.brosch@gmail.com>
Tue, 24 Jan 2012 20:14:35 +0000 (21:14 +0100)
committerJürg Billeter <j@bitron.ch>
Thu, 26 Jan 2012 20:20:39 +0000 (21:20 +0100)
vala/valaparameter.vala

index e34b773f2c4fc23cd424a4f8ac12f69befa464c6..22fe0c8ae3b519032f7707f692928b032529d9d1 100644 (file)
@@ -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");
                        }