Is Node.Remove() not working anymore?

Monkey Forums/Monkey Programming/Is Node.Remove() not working anymore?

MikeHart(Posted 2011) [#1]
I have list entries which I have removed since version 44 without a problem. I do it something like this:

Class ftTimer
	Field timerNode:list.Node<ftTimer> = Null
	Method Remove:Int()
		Self.timerNode.Remove()
		Return 0
	End
...


In version 46 it throws an error now:

Monkey runtime error: Illegal operation on removed node
/Users/michaelhartlef/Desktop/Monkey/MonkeyPro46/modules/monkey/list.monkey<214>


What do I need to change to make it work again?


MikeHart(Posted 2011) [#2]
Something must have changed in V45C also. In V44 it works flawless.

Damn!


Beaker(Posted 2011) [#3]
Have you tried RemoveEach() ?


DruggedBunny(Posted 2011) [#4]
This is the current code for Node.Remove:

	Method Remove()
#If CONFIG="debug"
		If Not _succ Error "Illegal operation on removed node"
#Endif
		_succ._pred=_pred
		_pred._succ=_succ
		_succ=Null
		_pred=Null
	End Method


This suggests to me that the only time you'd see it would be when you try to remove a Null node (_succ is assigned Self in the Node.New method), and you're in Debug mode. Even if it doesn't directly help, can you at least confirm whether or not these criteria apply?

Also, try sticking an If node = Null before your Remove call to determine whether or not you're trying to free a Null node...