From: Rico Tzschichholz Date: Thu, 28 Feb 2019 08:36:43 +0000 (+0100) Subject: vala: Correctly perform compatibility check of array length-type X-Git-Tag: 0.43.92~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fcc4a9235540c83f573086d573aae2ba03f63360;p=thirdparty%2Fvala.git vala: Correctly perform compatibility check of array length-type Regression of 36671ae5def89b46384e627a467247c834948254 https://gitlab.gnome.org/GNOME/vala/issues/607 --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 76b93f2c3..7f10b1606 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -70,6 +70,7 @@ TESTS = \ arrays/class-field-length-cname.vala \ arrays/field-global-length-cname.vala \ arrays/struct-field-length-cname.vala \ + arrays/incompatible-integer-elements.test \ chainup/base-class-invalid.test \ chainup/base-enum-invalid.test \ chainup/base-invalid.test \ diff --git a/tests/arrays/incompatible-integer-elements.test b/tests/arrays/incompatible-integer-elements.test new file mode 100644 index 000000000..f2bfc93fb --- /dev/null +++ b/tests/arrays/incompatible-integer-elements.test @@ -0,0 +1,5 @@ +Invalid Code + +void main () { + uint8?[] foo = new int?[13]; +} diff --git a/vala/valaarraytype.vala b/vala/valaarraytype.vala index 8265a8027..84522ca4c 100644 --- a/vala/valaarraytype.vala +++ b/vala/valaarraytype.vala @@ -235,12 +235,12 @@ public class Vala.ArrayType : ReferenceType { return false; } - if (element_type.compatible (target_array_type.element_type) - && target_array_type.element_type.compatible (element_type)) { - return true; + if (!length_type.compatible (target_array_type.length_type)) { + return false; } - if (length_type.compatible (target_array_type.length_type)) { + if (element_type.compatible (target_array_type.element_type) + && target_array_type.element_type.compatible (element_type)) { return true; }