It seems that if x?.y is used 65 535 times with x = null runtime errors appear. Those seem to be not directly related to the x?.y expression (almost as if other vars got corrupted). Specifically in the snippet below it's usually either "runtime error: type mismatch: cannot compare to 65535" or "runtime error: type mismatch: cannot compare /list (/list) to 65535" or even dream seeker straight up crashing. Note that it doesn't happen if the number is lowered to 65534, if z isn't null or if we access a variable instead of a proc.
Actually I lied, it happens for variables too but only if I do:
var/mob/z = null
for(var/i = 1; i <= 65535; i++)
z?.name
and not for e.g.
var/mob/z = null
for(var/i = 1; i <= 65535; i++)
z?.name = "what"
or
var/mob/z = null
for(var/i = 1; i <= 65535; i++)
if(z?.name) world.log << "what"
Also it seems to happen if this is done across multiple variables, not just z in the examples above / below.
Numbered Steps to Reproduce Problem:
1.) Run the snippet below (optionally replace mob and Bump with other types and procs).
2.) Stare in awe at the runtime error
Code Snippet (if applicable) to Reproduce Problem:
var/mob/z = null
for(var/i = 1; i <= 65535; i++)
z?.Bump()
Expected Results:
The code runs successfuly without calling Bump on anything.
Actual Results:
Runtime error or Dream Daemon crash.
Does the problem occur:
Every time? Or how often? Always.
In other games? N/A
In other user accounts? Probably.
On other computers? Yes.
When does the problem NOT occur?
When the number is less than 65 535.
When we access a variable using ?. and assign to it.
When we access a variable using ?. and use the value.
When the object ?. is called upon isn't null.
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
I haven't tested extensively but 513.1517 suffers from the problem too and I assume it probably existed for a long time.
Workarounds:
Use isnull(z) ? null : z.Bump() instead.