After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 709672 - ‘in’ operator doesn’t work for string*[] arrays
‘in’ operator doesn’t work for string*[] arrays
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
0.22.x
Other All
: Normal major
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2013-10-08 18:46 UTC by Philip Withnall
Modified: 2018-05-21 14:39 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Philip Withnall 2013-10-08 18:46:05 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.
Comment 1 Rico Tzschichholz 2018-05-21 14:39:06 UTC
This seems to got fixed a some time ago.