Fixes https://gitlab.gnome.org/GNOME/vala/issues/935
arrays/fixed-length-init0-not-allowed.vala \
arrays/field-global-length-cname.vala \
arrays/fixed-length-concat-invalid.test \
+ arrays/fixed-length-enum-value.vala \
arrays/fixed-length-non-const.test \
arrays/fixed-length-resize-invalid.test \
arrays/inline-field.test \
--- /dev/null
+enum Foo {
+ BAR = 23;
+}
+
+struct Bar {
+ public char array[Foo.BAR];
+}
+
+void foo (uint array[Foo.BAR]) {
+ assert (array.length == 23);
+}
+
+void main () {
+ int array[Foo.BAR];
+ assert (array.length == 23);
+
+ var bar = Bar ();
+ assert (bar.array.length == 23);
+}
if (fixed_length && length != null) {
length.check (context);
- if (length.value_type == null || !(length.value_type is IntegerType) || !length.is_constant ()) {
+ if (length.value_type == null || !(length.value_type is IntegerType || length.value_type is EnumValueType)
+ || !length.is_constant ()) {
error = true;
Report.error (length.source_reference, "Expression of constant integer type expected");
return false;