Skip to content

Correct the assignment operators for element of string arrays and nullable basic type arrays

Akarin requested to merge akarin123/vala:string_array_append into master

This draft tries to address issue #889 (closed). Now vala should correctly convert += to strcat operation for element of string arrays. This draft also corrects the conversion of various assignment operators for element of nullable simple type arrays (issue #1258 (closed)).

The following code should work now

void main () {
	int?[] arr = {1, 2, 3};
	string[] strs = {"foo","bar","foobar"};
	arr[0] += 1;
	arr[1] *= 3;
	arr[2] -= 2;
    
	strs[0] += arr[0].to_string ();
	strs[1] += arr[1].to_string ();
	strs[2] += arr[2].to_string ();

	assert (strs[0] == "foo2");
	assert (strs[1] == "bar6");
	assert (strs[2] == "foobar1");
}
Edited by Rico Tzschichholz

Merge request reports