From: Florian Brosch Date: Tue, 24 Jan 2012 20:14:35 +0000 (+0100) Subject: Check type of default arguments X-Git-Tag: 0.15.1~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ddfac77ab73e8a1d10070f08fa2120b5cf3713bb;p=thirdparty%2Fvala.git Check type of default arguments --- diff --git a/vala/valaparameter.vala b/vala/valaparameter.vala index e34b773f2..22fe0c8ae 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"); }