Skip to content

Commit

Permalink
vala: Issue warning when passing arrays to typeof(), except for "stri…
Browse files Browse the repository at this point in the history
…ng[]"

Passing arrays resolve to G_TYPE_INVALID, and "string[]" to G_TYPE_STRV

See https://gitlab.gnome.org/GNOME/vala/issues/868
  • Loading branch information
ricotz committed Oct 28, 2019
1 parent 567a14f commit bb53571
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vala/valatypeofexpression.vala
Expand Up @@ -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;
}

Expand Down

0 comments on commit bb53571

Please sign in to comment.