summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2019-10-23 14:21:49 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2019-11-07 11:53:40 +0100
commitc87fec49865d43dd7fe846da917d4f24a8a52786 (patch)
tree791c1c4e9b2364583b323e90b305cff11b584bfb
parent998d2e9568884f903000ef3d3695e9011d0b58de (diff)
downloadvala-c87fec49865d43dd7fe846da917d4f24a8a52786.tar.gz
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
-rw-r--r--vala/valatypeofexpression.vala4
1 files changed, 4 insertions, 0 deletions
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;
}