ID:2588075
 
BYOND Version:513
Operating System:Windows 10 Enterprise 64-bit
Web Browser:Chrome 70.0.3538.102
Applies to:Dream Maker
Status: Open

Issue hasn't been assigned a status value.
Descriptive Problem Summary:
When using the keywords global or static as part of a path (strictly /obj/global as opposed to, for example, /obj/global_object) and override a proc, src no longer references the expected instance.
It is also not possible to properly to have subtypes of such paths, nor define new procs.

Numbered Steps to Reproduce Problem:
1: Define a path with either of the keywords global or static in it, for example: /obj/global
2: Override a proc of the base type and use the src reference
3: Define a subtype of the path
4: Define a new proc for the path

Code Snippet (if applicable) to Reproduce Problem:
/obj
name = "Base Type"

/obj/proc/ReturnSrc()
return src

// Will return src as expected
/obj/without_proc_override/global
name = "Global - Without Proc Override"

/*
// A subtype won't compile, results in: error: returnsrc: undefined type: src
/obj/without_proc_override/global/subtype
name = "Global - Without Proc Override - Subtype"

/obj/without_proc_override/global/subtype/ReturnSrc()
return src
*/


// Will generally return null. Will rarely return a list which cannot be enumerated (results in a bad save error), or another random instance (of any kind)
/obj/with_proc_override/global
name = "With Proc Override"

/obj/with_proc_override/global/ReturnSrc()
return src

// Cannot be called, results in: NewSrcProc: undefined proc
/obj/global/proc/NewSrcProc()
return src

/world/New()
..()
var/list/obj_paths = list(
/obj,
/obj/without_proc_override/global,
// /obj/without_proc_override/global/subtype, // Doesn't compile, as per comment by definition
/obj/with_proc_override/global
)

for(var/type in obj_paths)
var/obj/O = new type(world)
world.log << "Type: [type], src: [O.ReturnSrc()]"

var/obj/global/O = new()
// world.log << "SRC: [O.NewSrcProc()]" // Doesn't compile, as per comment by definition

del(src)


Expected Results:
Either the following output:
Type: /obj, src: Base Type
Type: /obj/without_proc_override/global, src: Global - Without Proc Override
Type: /obj/without_proc_override/global, src: Global - Without Proc Override - Subtype
Type: /obj/with_proc_override/global, src: Global - With Proc Override

As well as for it to be possible to:
Have subtypes of paths with global/static in them, for example: /obj/global/subtype
Have paths with global/static in them to have new, callable procs, for example: /obj/global/proc/NewProc()

Or:
The compiler not allowing keywords such as global/static in paths, and report it as an error.

Actual Results:
Type: /obj, src: Base Type
Type: /obj/without_proc_override/global, src: Global - Without Proc Override
Type: /obj/with_proc_override/global, src: (usually null)
(Or compilation errors, when troublesome lines are uncommented)

Does the problem occur:
Every time? Or how often? Every time
In other games? Most likely
In other user accounts? Most likely
On other computers? Most likely

When does the problem NOT occur?
When you do not use the global/static keywords as part of a path
When you do not override procs for such paths
When you do not subtype such paths

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.)
If memory serves this has happened since 511 and probably before

Workarounds:
Do not use the global/static keyword when defining a path