From: Simon Werbeck Date: Sat, 6 Apr 2013 06:51:19 +0000 (+0200) Subject: Warn if a parameter without default follows a parameter with default value X-Git-Tag: 0.21.2~28 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fkeep-around%2Fb22255aa25e0296211ea7ca404970d1677747180;p=thirdparty%2Fvala.git Warn if a parameter without default follows a parameter with default value Fixes bug 644241. --- diff --git a/vala/valamethod.vala b/vala/valamethod.vala index 5e5f82649..f1b757777 100644 --- a/vala/valamethod.vala +++ b/vala/valamethod.vala @@ -654,12 +654,18 @@ public class Vala.Method : Subroutine { Report.error (parameters[0].source_reference, "Named parameter required before `...'"); } + var optional_param = false; foreach (Parameter param in parameters) { param.check (context); if (coroutine && param.direction == ParameterDirection.REF) { error = true; Report.error (param.source_reference, "Reference parameters are not supported for async methods"); } + if (optional_param && param.initializer == null) { + Report.warning (param.source_reference, "parameter without default follows parameter with default"); + } else if (param.initializer != null) { + optional_param = true; + } } foreach (DataType error_type in get_error_types ()) { diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi index 9f6d77c1a..934d026eb 100644 --- a/vapi/glib-2.0.vapi +++ b/vapi/glib-2.0.vapi @@ -3449,7 +3449,7 @@ namespace GLib { public string[] split_full (string str, ssize_t string_len = -1, int start_position = 0, RegexMatchFlags match_options = 0, int max_tokens = 0) throws RegexError; public string replace (string str, ssize_t string_len, int start_position, string replacement, RegexMatchFlags match_options = 0) throws RegexError; public string replace_literal (string str, ssize_t string_len, int start_position, string replacement, RegexMatchFlags match_options = 0) throws RegexError; - public string replace_eval (string str, ssize_t string_len, int start_position, RegexMatchFlags match_options = 0, RegexEvalCallback eval) throws RegexError; + public string replace_eval (string str, ssize_t string_len, int start_position, RegexMatchFlags match_options, RegexEvalCallback eval) throws RegexError; public static bool check_replacement (out bool has_references = null) throws RegexError; }