Open sdfgeoff opened 1 year ago
You can use the is_same()
function instead of the ==
operator for a stricter and safer comparison. I'm not sure if we should change the behavior of dictionaries. On the one hand, this was done for String
vs StringName
. On the other hand, in addition to int
vs float
, we have many other similar types like Vector2i
vs Vector2
, and what’s even worse, PackedInt64Array
vs PackedFloat64Array
, Array[int]
vs Array[float]
(they can also be dictionary keys). And dictionaries are not the only place where comparisons are more strict, for example match
also compares values differently than the ==
operator.
Godot version
4.1.1 stab;e
System information
arch
Issue description
In gdscript, a float can be compared to an int:
You can also use floats an ints as dictionary keys:
But dictionary keys don't do equality, so:
I don't know that this needs to be fixed as it is (in hindsight) obvious that this is how it would work, but it did leave me on a merry bughunt, and printing the values/comparing equality didn't reveal the issue.
Steps to reproduce
Minimal reproduction project
Code example above