diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2020-07-03 19:33:41 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2020-07-04 13:05:48 +0200 |
commit | 502686203c2f21067783eada6af6465ce0d3d318 (patch) | |
tree | 4b6aea891d306b62fe7446b76bdf1df72abc42e6 /vala/valamemberaccess.vala | |
parent | 7d3b60848803ddbfe583ecc13f020fea0762f6c9 (diff) | |
download | vala-502686203c2f21067783eada6af6465ce0d3d318.tar.gz |
vala: Don't allow "resize" invocation on variable with unowned array type
Fixes https://gitlab.gnome.org/GNOME/vala/issues/928
Diffstat (limited to 'vala/valamemberaccess.vala')
-rw-r--r-- | vala/valamemberaccess.vala | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala index 5e810d699..db022fefd 100644 --- a/vala/valamemberaccess.vala +++ b/vala/valamemberaccess.vala @@ -487,11 +487,15 @@ public class Vala.MemberAccess : Expression { } } - 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; } } } |