GNOME Bugzilla – Bug 684742
Soft assertion and invalid C code when using ternary operator to initialize structure
Last modified: 2013-04-30 07:10:18 UTC
With Vala 0.18.0 (and possibly older versions, I found this with brand-new code), I get soft assertions and bad C code when using a ternary operator to initialize a struct's fields. For example: struct Frotz { int nitfol; } void main(string[] args) { // This causes soft assertions and invalid C code Frotz f = Frotz() { nitfol = (args.length > 2) ? 42 : 23 }; // this is only to prevent unused-variable compiler warnings f.nitfol = 0; } yields these errors: ** (valac:19708): CRITICAL **: vala_block_insert_before: assertion `stmt != NULL' failed ** (valac:19708): CRITICAL **: vala_block_insert_before: assertion `stmt != NULL' failed /home/jim/test/test.vala.c: In function ‘_vala_main’: /home/jim/test/test.vala.c:54:11: error: ‘_tmp0_’ undeclared (first use in this function) Removing the ternary operator avoids the problem.
Created attachment 225109 [details] Minimal test case.
Thanks for taking the time to report this bug. This particular bug has already been reported into our bug tracking system, but we are happy to tell you that the problem has already been fixed. It should be solved in the next software version. You may want to check for a software upgrade. *** This bug has been marked as a duplicate of bug 603056 ***