arrays/struct-field-initializer.vala \
arrays/struct-namespaced-initializer.vala \
arrays/incompatible-integer-elements.test \
+ arrays/resize.vala \
+ arrays/resize-unowned-invalid.test \
+ arrays/resize-unowned-invalid-2.test \
+ arrays/resize-unowned-invalid-3.test \
arrays/slice-invalid-start.test \
arrays/slice-invalid-stop.test \
arrays/slice-no-array.test \
--- /dev/null
+Invalid Code
+
+void bar (string[] foo) {
+ foo.resize (42);
+}
+
+void main () {
+ var foo = new string[23];
+ bar (foo);
+}
--- /dev/null
+Invalid Code
+
+unowned string[] foo;
+
+void main () {
+ var bar = new string[23];
+ foo = bar;
+ foo.resize (42);
+}
--- /dev/null
+Invalid Code
+
+void main () {
+ var foo = new string[23];
+ unowned string[] bar = foo;
+ bar.resize (42);
+}
--- /dev/null
+void bar (ref string[] foo) {
+ foo.resize (42);
+}
+
+void manam (out string[] foo) {
+ foo = new string[23];
+ foo.resize (42);
+}
+
+string[] boo;
+
+void main () {
+ {
+ var foo = new string[23];
+ foo.resize (42);
+ }
+ {
+ var foo = new string[23];
+ bar (ref foo);
+ }
+ {
+ string[] foo;
+ manam (out foo);
+ }
+ {
+ boo = new string[23];
+ boo.resize (42);
+ }
+}
}
}
- if (symbol_reference is ArrayResizeMethod && inner.value_type is ArrayType) {
- unowned ArrayType? value_array_type = inner.value_type as ArrayType;
- if (value_array_type != null && value_array_type.inline_allocated) {
+ if (symbol_reference is ArrayResizeMethod && inner.symbol_reference is Variable) {
+ // require the real type with its original value_owned attritubte
+ var inner_type = context.analyzer.get_value_type_for_symbol (inner.symbol_reference, true) as ArrayType;
+ if (inner_type != null && inner_type.inline_allocated) {
Report.error (source_reference, "`resize' is not supported for arrays with fixed length");
error = true;
+ } else if (inner_type != null && !inner_type.value_owned) {
+ Report.error (source_reference, "`resize' is not allowed for unowned array references");
+ error = true;
}
}
}