diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2021-06-06 18:11:02 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2021-06-06 19:10:46 +0200 |
commit | 9bd652886ad889213ca7c94a0b846947fdb226d3 (patch) | |
tree | 9b5f608c86a885e2ff68990305b3e805fd40238f /tests | |
parent | 0fa66cafcbc17c127b486ba7b5483b1cf350f24c (diff) | |
download | vala-9bd652886ad889213ca7c94a0b846947fdb226d3.tar.gz |
codegen: Allow null to initialize non-null struct inside initializer list
Fixes https://gitlab.gnome.org/GNOME/vala/issues/594
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/arrays/struct-initializer-null.vala | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 3e754e58e..5dfcd32a9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -125,6 +125,7 @@ TESTS = \ arrays/length-no-int-type.test \ arrays/struct-field-length-cname.vala \ arrays/struct-field-initializer.vala \ + arrays/struct-initializer-null.vala \ arrays/struct-namespaced-initializer.vala \ arrays/incompatible-integer-elements.test \ arrays/resize.vala \ diff --git a/tests/arrays/struct-initializer-null.vala b/tests/arrays/struct-initializer-null.vala new file mode 100644 index 000000000..325f95b34 --- /dev/null +++ b/tests/arrays/struct-initializer-null.vala @@ -0,0 +1,12 @@ +struct Foo { + public unowned string s; + public int i; +} + +const Foo[] FOOS = { { "foo", 23 }, {} }; +const Foo[] BARS = { { "bar", 42 }, null }; + +void main () { + Foo[] foos = { { "foo", 23 }, {} }; + Foo[] bars = { { "bar", 42 }, null }; +} |