godot: NodePath cant be compared with null

Operating system or device, Godot version, GPU Model and driver (if graphics related): Linux, 3d06957f12ba5c04702f3db980af9c07142e7886

Issue description: It’s impossible to compare NodePath with null. It will give Invalids operands 'NodePath' and 'Nil' in operator '=='. error

Steps to reproduce:

  1. Create new scene.
  2. Add Node type to the scene root
  3. Attach this script to the Node:
extends Node
var someNodePath = NodePath();
func _ready():
	if(someNodePath == null):  #Invalids operands 'NodePath' and 'Nil' (...)
		pass
	else:
		print("it's ok");

  1. Run the scene

Update 1: From my bisection it seems that 137f8a5 is the first bad commit

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments

Oh, but the comparison should return false instead of erroring, right.

It was done on purpose, however not adding the option back to booleanize the types was an oversight.