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 535849 - Confusing valac error message at ownership transfer
Confusing valac error message at ownership transfer
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
0.3.x
Other All
: Normal minor
: ---
Assigned To: Jürg Billeter
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2008-05-30 20:48 UTC by Tomaz Vajngerl
Modified: 2008-06-04 15:00 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Tomaz Vajngerl 2008-05-30 20:48:27 UTC
At compiling valac produces the following error:

valaNonGobjectClass.vala:13.3-13.9: error: duplicating Node instance, use weak variable or explicitly invoke copy method
		Node<G> node = new Node<G>();
		^^^^^^^

** (valac:23238): CRITICAL **: vala_ccode_assignment_new: assertion `VALA_IS_CCODE_EXPRESSION (r)' failed

** (valac:23238): CRITICAL **: vala_ccode_comma_expression_append_expression: assertion `VALA_IS_CCODE_EXPRESSION (expr)' failed

The code:

using GLib;

public class SomeClass<G> : Object {

	[Compact]
	private class Node<G> {
		public Node<G> next = null;
	}

	Node<G> first = new Node<G>();

	public void create() {
		Node<G> node = new Node<G>();

		node.next = #first;
		first = node;
	}

}

public static void main(string[] args) {
	var i = new SomeClass<int>();
	i.create();
}

The problem is at line: "first = node;" in create method as it node doesn't transfer ownership to first, but as vala reports the error being with ownership transfer at "Node<G> node = new Node<G>();"
Comment 1 Jürg Billeter 2008-06-04 14:56:51 UTC
Confirming.
Comment 2 Jürg Billeter 2008-06-04 15:00:01 UTC
2008-06-04  Juerg Billeter  <j@bitron.ch>

        * gobject/valaccodeassignmentbinding.vala:
        * gobject/valaccodegenerator.vala:

        Fix error reporting when duplicating non-reference counted objects,
        fixes bug 535849

Fixed in r1563.