GNOME Bugzilla – Bug 622178
valac emits non-compilable C for nested field initializers
Last modified: 2018-02-15 22:35:17 UTC
I'm not entirely sure this is valid Vala but I expect it to yield either an valac error message or compilable C code. Confirmed broken on git master june 20th (5f3df0d). struct png_chunk { uint32 length; uint32 type; uchar[] data; uint32 crc; } void main (string[] args) { png_chunk chunk = {0, 0, {0, 0, 0, 0}, 0}; if (chunk.length == chunk.type || chunk.crc == 0 || chunk.data == null) stdout.printf ("blah\n"); }
Thanks for your bug report. This is still an issue with 0.39.7. As with all cases of "acceptable" Vala code leading to invalid C code, we should try to fix this either way or another before 1.0.
Created attachment 368373 [details] [review] vala: Properly handle array-initializers inside struct-initializers
Review of attachment 368373 [details] [review]: Awesome. Would have never expected that this could be solved with a one-liner. Thanks!
Review of attachment 368373 [details] [review]: This patch causes regressions. So I will look into it further.
Created attachment 368378 [details] [review] vala: Properly handle array-initializers inside struct-initializers
Created attachment 368388 [details] [review] vala: Properly handle array-initializers inside struct-initializers
Attachment 368388 [details] pushed as 03395c0 - vala: Properly handle array-initializers inside struct-initializers