### Godot version

Godot 4 0160fea1ced6697d5b72ad2f41332e8768080be4

### System information

Windows 10 64 bits NVIDIA GeForce GTX 1060

### Issue description

The symptom of this in my project is the following:
```gdscript
not list.has(42)
```
Under particular runtime conditions, this code produces an error:
```
SCRIPT ERROR: Invalid operands 'bool' and 'int' in operator 'not'.
```
![image](https://user-images.githubusercontent.com/1311555/210856995-8f82630d-69a7-42ca-a18b-9fca29f5ec51.png)

When normally there is no reason for such code to cause this error, because `has` returns `bool`, and `not` takes only a `bool`.

After investigation, it turns out the GDScript VM ends up with two operands when executing the `NOT` operation: `bool` and `int`, instead of `bool` and `nil`.
The VM uses a special operand address for nil, but in this case, a non-nil value has been stored in it.
This behavior seems to have been introduced by this PR: https://github.com/godotengine/godot/pull/70702#issuecomment-1371704072

Thanks to @vonagam for investigating and confirming the in-game reproduction.

### Steps to reproduce

I was unable reproduce this in a simple project. It only happens in a big project, which is currently not open-source. However, the reproduction steps *in the game* are quick, and reliably cause the bug every time.

Just in case, below is a simplification of the impacted code that runs in the game when the issue occurs. This is what I tried as an MRP, unfortunately, it does not reproduce the issue alone, despite the affected data being relatively isolated. There are probably external implications which are hard to track down.
```gdscript
extends RigidBody3D

# custom RefCounted script
const BlockInstance = preload("./block_instance.gd")

# custom RefCounted script, with a `tags` array variable containing integers
const Block = preload("./block.gd")

var _dict := {}

func _ready():
	var block = Block.new()
	# The following instructions mimick a series of actions done in the game.

	var b0 = BlockInstance.new()
	
	var b1 = BlockInstance.new()
	add(b1, block)
	
	var b2 = BlockInstance.new()
	add(b2, block)
	
	remove(b1, block)
	b1 = null
	
	var b3 = BlockInstance.new()
	add(b3, block)


func add(bi: BlockInstance, block: Block):
	if len(block.tags) > 0:
		for tag in block.tags:
			var list = _dict.get(tag, null)
			if list == null:
				list = []
				_dict[tag] = list
			else:
				print("list is ", typeof(list))
				# This is where the error occurs at the last call to `add`
				assert(not list.has(bi))
			list.append(bi)


func remove(bi: BlockInstance, block):
	if len(block.tags) > 0:
		for tag in block.tags:
			var list = _dict[tag]
			list.erase(bi)
```

If you need to reproduce the issue, you can contact me.


### Minimal reproduction project

N.A
switch (function->return_type.kind) {
			case GDScriptDataType::BUILTIN: {
				if (function->return_type.builtin_type == Variant::ARRAY && function->return_type.has_container_element_type()) {
					const GDScriptDataType &element_type = function->return_type.get_container_element_type();
					Variant script = function->return_type.script_type;
					int script_idx = get_constant_pos(script);
					script_idx |= (GDScriptFunction::ADDR_TYPE_CONSTANT << GDScriptFunction::ADDR_BITS);
					append_opcode(GDScriptFunction::OPCODE_RETURN_TYPED_ARRAY);
					append(p_return_value);
					append(script_idx);
					append(element_type.kind == GDScriptDataType::BUILTIN ? element_type.builtin_type : Variant::OBJECT);
					append(element_type.native_type);
				} else {
					append_opcode(GDScriptFunction::OPCODE_RETURN_TYPED_BUILTIN);
					append(p_return_value);
					append(function->return_type.builtin_type);
				}
			} break;
			case GDScriptDataType::NATIVE: {
				append_opcode(GDScriptFunction::OPCODE_RETURN_TYPED_NATIVE);
				append(p_return_value);
				int class_idx = GDScriptLanguage::get_singleton()->get_global_map()[function->return_type.native_type];
				Variant nc = GDScriptLanguage::get_singleton()->get_global_array()[class_idx];
				class_idx = get_constant_pos(nc) | (GDScriptFunction::ADDR_TYPE_CONSTANT << GDScriptFunction::ADDR_BITS);
				append(class_idx);
			} break;
			case GDScriptDataType::GDSCRIPT:
			case GDScriptDataType::SCRIPT: {
				Variant script = function->return_type.script_type;
				int script_idx = get_constant_pos(script) | (GDScriptFunction::ADDR_TYPE_CONSTANT << GDScriptFunction::ADDR_BITS);