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 744797 - Using foreach requires (!) operator
Using foreach requires (!) operator
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Non-null
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2015-02-19 15:55 UTC by fakey
Modified: 2018-05-22 15:21 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description fakey 2015-02-19 15:55:54 UTC
Compiling this with experimental non-null enabled:

void main () {
	var array = new Variant.parsed ("[1, 2, 3]");

	foreach (var item in array) {
		print ("%d", item.get_int32 ());
	}
}

Results in:

fail.vala:5.16-5.29: error: Access to instance member `GLib.Variant.get_int32' from nullable reference denied
		print ("%d", item.get_int32 ());
		             ^^^^^^^^^^^^^^
Compilation failed: 1 error(s), 0 warning(s)

But it shouldn't be necessary since item can't be null. The iterator interface stops when next_value() returns null, and get() returns T, not T?.
Comment 1 GNOME Infrastructure Team 2018-05-22 15:21:21 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/489.