diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2021-04-11 18:05:08 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2021-04-11 18:05:38 +0200 |
commit | c9c7c782f02843061fa9d13dfba917ad8f295272 (patch) | |
tree | 1eb143f60ba3778fc6a188c2d6dd5ec49f8fbbaf /tests | |
parent | f5203f73468b33b3d343d4b863e3e4eea2e8a295 (diff) | |
download | vala-c9c7c782f02843061fa9d13dfba917ad8f295272.tar.gz |
codegen: Don't free temp-var for element-access to array with boxed structs
Check the symbol_reference of inner element-access as needed.
Regression of 63551acaf0d83fac8b50904c2759c1098fbfaa71
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1174
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/arrays/cast-struct-boxed-element-access.vala | 22 |
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index a802bc8fb..346c67e2d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -100,6 +100,7 @@ TESTS = \ constants/strings.vala \ namespace/unique.vala \ arrays/cast-silent-invalid.test \ + arrays/cast-struct-boxed-element-access.vala \ arrays/class-field-initializer.vala \ arrays/class-field-length-cname.vala \ arrays/constant-element-access.vala \ diff --git a/tests/arrays/cast-struct-boxed-element-access.vala b/tests/arrays/cast-struct-boxed-element-access.vala new file mode 100644 index 000000000..356ecbd50 --- /dev/null +++ b/tests/arrays/cast-struct-boxed-element-access.vala @@ -0,0 +1,22 @@ +struct Foo { + public int i; +} + +void main () { + var foo = new Foo?[] { { 23 }, { 42 }, { 4711 } }; + { + Foo f = foo[0]; + assert (f.i == 23); + assert (foo[0].i == 23); + } + { + Foo f = (Foo) foo[1]; + assert (f.i == 42); + assert (foo[1].i == 42); + } + { + Foo f = (!) foo[2]; + assert (f.i == 4711); + assert (foo[2].i == 4711); + } +} |