diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2023-03-16 21:50:41 +0100 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2023-03-19 09:32:26 +0100 |
commit | ed68b9f412bd6932e384cc8c6ac89257ae40142f (patch) | |
tree | 27ad4e6322fa643cc0ed021de1153dc3fc9a39a2 /vala/valaunaryexpression.vala | |
parent | a902d7eae96a3f1ab0cb64f268443b23ee8ab45a (diff) | |
download | vala-ed68b9f412bd6932e384cc8c6ac89257ae40142f.tar.gz |
vala: Set proper value-type of unary ref/out expression in initializers
So the expected pointer-type for these expressions is available in AST.
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1421
Diffstat (limited to 'vala/valaunaryexpression.vala')
-rw-r--r-- | vala/valaunaryexpression.vala | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/vala/valaunaryexpression.vala b/vala/valaunaryexpression.vala index a725456fa..b45d7da83 100644 --- a/vala/valaunaryexpression.vala +++ b/vala/valaunaryexpression.vala @@ -218,7 +218,12 @@ public class Vala.UnaryExpression : Expression { (ea != null && ea.container.value_type is ArrayType)) { // ref and out can only be used with fields, parameters, local variables, and array element access lvalue = true; - value_type = inner.value_type; + // `ref foo` or `out foo` is used as synonym for `&foo` + if (parent_node is InitializerList || parent_node is MemberInitializer) { + value_type = new PointerType (inner.value_type, inner.source_reference); + } else { + value_type = inner.value_type; + } } else { error = true; Report.error (source_reference, "ref and out method arguments can only be used with fields, parameters, local variables, and array element access"); |