ID:2665357
 
Resolved
The ?: operator could sometimes get confused and call a global proc with the same name as a datum proc, and so could ?. when given a var with no type.
BYOND Version:513
Operating System:Windows 10 Pro
Web Browser:Chrome 89.0.4389.90
Applies to:Dream Maker
Status: Resolved (514.1553)

This issue has been resolved.
Descriptive Problem Summary:
If a global proc with the same name as a member proc is called using type-less `?.` or `?:`, the global proc will be called.

Sorry if this has already been reported, but it's hard to search for "?:".

Code Snippet (if applicable) to Reproduce Problem:
/proc/my_proc()
world.log << "global::my_proc"

/datum/proc/my_proc()
world.log << "datum::my_proc"

/world/New()
var/datum/x = new()
x?.my_proc()
x?:my_proc()

var/y = x
y?.my_proc()


Expected Results:
datum::my_proc
datum::my_proc
datum::my_proc

Actual Results:
datum::my_proc
global::my_proc
global::my_proc

Does the problem occur:
Every time

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked?
The behaviour is the same on 513.1534 and 514.1549. I didn't try further back.

Looks like I under-thought this a bit. The same behaviour occurs with normal call syntax too (no question marks) as long as the variable has no type hints.
Lummox JR resolved issue with message:
The ?: operator could sometimes get confused and call a global proc with the same name as a datum proc, and so could ?. when given a var with no type.