GNOME Bugzilla – Bug 709672
‘in’ operator doesn’t work for string*[] arrays
Last modified: 2018-05-21 14:39:06 UTC
If one tries to use the ‘in’ operator on a string*[] array, valac emits a critical warning and generates invalid C code. For example: string*[] my_array = my_variant.get_strv (); var my_bool = ("foobar" in my_array); results in the following compiler output: ** (valac:2432): CRITICAL **: vala_ccode_base_module_get_ccode_lower_case_name: assertion 'node != NULL' failed ofono-backend.c:215:17: warning: function declaration isn't a prototype [-Wstrict-prototypes] static gboolean _vala_(null)_array_contains (const gchar** stack, int stack_length, const gchar* needle); This is caused by the following generated C code: static gboolean _vala_(null)_array_contains (const gchar** stack, int stack_length, const gchar* needle); … static gboolean _vala_(null)_array_contains (const gchar** stack, int stack_length, const gchar* needle) { int i; for (i = 0; i < stack_length; i++) { if (g_strcmp0 (stack[i], needle) == 0) { return TRUE; } } return FALSE; } This is with Vala 75359c3cab2e979d087ce0a19735bf86add33b42.
This seems to got fixed a some time ago.