ID:2902087
 
Not a bug
BYOND Version:515.1620
Operating System:Windows 10 Home 64-bit
Web Browser:Firefox 115.0
Applies to:byondapi
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
Descriptive Problem Summary:

ByondValue_GetRef returns the ID of a valid ref, and 0 for an invalid ref. The world, and the first-ever object of a given ref type to be instantiated, both have an ID of 0. This results in ambiguity. Given how many reference-counted objects the typical BYOND game uses, this is an extremely niche edge case, but I believe it should be addressed nevertheless.

Numbered Steps to Reproduce Problem:
1. Pass a non-reference type (e.g. a number) to ByondValue_GetRef.
2. Pass the first-ever datum/area/turf/obj/mob to be created since world creation to ByondValue_GetRef.
3. Compare the two return values.

Code Snippet (if applicable) to Reproduce Problem:
DM:
world/New()
world.log << call_ext("external_lib", "byond:compare")(1, new/obj())

C++:
#include <byondapi.h>
#include <byondapi_cpp_wrappers.h>
extern "C" BYOND_EXPORT CByondValue compare(int n, ByondValue arg[])
{
ByondValue ret;
if(arg[0].get_ref() == arg[1].get_ref)
{
ret = 1.0f;
}
else
{
ret = 0.0f;
}
return ret;
}

Expected Results:
The two return values should not be equal

Actual Results:
The two return values are equal

The ByondValue_GetRef() function isn't meant to be used with non-reference types, so there is no ambiguity.

Also the code snippet included is incorrect, since the C++ wrappers don't define any function called get_ref(); the actual function is ByondValue::GetRef(). This code won't compile as-is.
Lummox JR resolved issue (Not a bug)