Left operand of 'is' is a previously freed instance in Godot 4
The variable still points at a node that was freed, and 'is' cannot check the type of a freed object. n is Node after n.free() stops with Left operand of 'is' is a previously freed instance. Test is_instance_valid(n) first; it returns false for a freed object.
AppImage, x86_64. Ubuntu 22.04, Debian 12, Fedora 39 or newer.
Intel or AMD Chromebook, with Linux turned on.
What Godot is checking
Freeing a node does not clear the variables that refer to it. They keep a reference to an object that no longer exists, which Godot calls a previously freed instance.
The is operator looks up the object to compare its class. When the object is gone it cannot, and the VM stops with this message.
More on this: Cannot call method '…' on a previously freed instance in Godot 4
Reproduce it
A node freed, then type-checked with is.
extends Node
func _ready() -> void:
var enemy := Node.new()
enemy.free()
print(enemy is Node)
print("after")
What Godot 4.7.2 prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
SCRIPT ERROR: Left operand of 'is' is a previously freed instance.
at: _ready (res://answers/left-operand-of-is-is-a-previously-freed-instance/repro.gd:6)
GDScript backtrace (most recent call first):
[0] _ready (res://answers/left-operand-of-is-is-a-previously-freed-instance/repro.gd:6)Fix it
Check that the object still exists before checking its type.
extends Node
func _ready() -> void:
var enemy := Node.new()
enemy.free()
if is_instance_valid(enemy) and enemy is Node:
print("still here")
else:
print("enemy is gone")
What the fixed script prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
enemy is goneRun this fix with your agent
Flockbay is the Godot editor with an AI agent built in. Paste this into Flockbay's chat, or into Claude Code or Codex connected to Flockbay over MCP: the agent finds the cause in your project, applies the fix, runs the game headless and reads Godot's output to check it.
More on this: Attempted to free a RefCounted object in Godot 4
My Godot 4 project prints this error: "Left operand of 'is' is a previously freed instance.". Find where it comes from and fix it. The variable still points at a node that was freed, and 'is' cannot check the type of a freed object. n is Node after n.free() stops with Left operand of 'is' is a previously freed instance. Test is_instance_valid(n) first; it returns false for a freed object. Then run the game headless and check that Godot's output no longer shows it.queue_free() frees it at the end of the frame
queue_free() does not free a node at once: it is freed at the end of the current frame. A reference kept in an array or a variable is still pointing at it on the next frame, and an is check there fails the same way. Remove it from your arrays when you free it, or test is_instance_valid().
Verified on Godot 4.7.2
Both scripts on this page were run headless on Godot 4.7.2 (4.7.2.stable.mono.official.ed1daf0bf) on 18 October 2026, and the output above is what Godot printed, unedited.
Where the check lives in Godot's source: gdscript_vm.cpp line 945, the message.
Questions
- Does is_instance_valid() work on null?
- Yes. It returns false for null and for a freed object, and true for an object that exists.
- Why is the variable not null after free()?
- GDScript does not clear references to a freed object. Set the variable to null yourself after freeing, or check is_instance_valid().
Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot.
Download Flockbay free