If statement executing even though argument is false

I have a function to check if an inventory slot is available, but the if statement has begun executing even if its argument is false. This only started happening after I changed some stuff before this function is called from another class, but nothing witthin this class itself. Am I missing something obvious or is my project cursed?

Is it executing? You are not stopped on line 24. Add a breakpoint there and see if it hits it.

Well we don’t know much about what item and parentSlot actually are. I never really tested this in the debugger but it might be possible that the watches VS is evaluating doesn’t use Unity’s overloaded == operator. So if your item and parentSlot references are of a type that is derived from UnityEngine.Object, technically they might not be null but both point to objects which have been destroyed / wrongly created. The overloaded == operator would fake that the objects are null in that case. This could be a bug in VS

If you have never heard about the custom == operator I highly recommend to read this blog post. Even if you already know about the == operator but haven’t read the blog post yet, I still recommend reading it. It’s a fundamental part of Unity to understand the two sides and how they interact with each other.

Note that this is just a guess based on what we can see in your question.