From: Rico Tzschichholz Date: Wed, 23 Oct 2019 12:21:49 +0000 (+0200) Subject: vala: Issue warning when passing arrays to typeof(), except for "string[]" X-Git-Tag: 0.44.10~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c87fec49865d43dd7fe846da917d4f24a8a52786;p=thirdparty%2Fvala.git vala: Issue warning when passing arrays to typeof(), except for "string[]" Passing arrays resolve to G_TYPE_INVALID, and "string[]" to G_TYPE_STRV See https://gitlab.gnome.org/GNOME/vala/issues/868 --- diff --git a/vala/valatypeofexpression.vala b/vala/valatypeofexpression.vala index 5aa28e1fd..06b19ff5d 100644 --- a/vala/valatypeofexpression.vala +++ b/vala/valatypeofexpression.vala @@ -86,6 +86,10 @@ public class Vala.TypeofExpression : Expression { Report.warning (_data_type.source_reference, "Type argument list without effect"); } + if (_data_type is ArrayType && ((ArrayType) _data_type).element_type.data_type != context.analyzer.string_type.data_type) { + Report.warning (_data_type.source_reference, "Arrays do not have a `GLib.Type', with the exception of `string[]'"); + } + return !error; }