]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Issue warning when passing arrays to typeof(), except for "string[]"
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 23 Oct 2019 12:21:49 +0000 (14:21 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 7 Nov 2019 10:53:40 +0000 (11:53 +0100)
Passing arrays resolve to G_TYPE_INVALID, and "string[]" to G_TYPE_STRV

See https://gitlab.gnome.org/GNOME/vala/issues/868

vala/valatypeofexpression.vala

index 5aa28e1fd7191295ebfdd3ef08976cda33191b2b..06b19ff5da1b2e3e0e9a53b2b8d49776161250d8 100644 (file)
@@ -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;
        }