ID:2441385
 
BYOND Version:512
Operating System:Windows 7 Ultimate 64-bit
Web Browser:Firefox 66.0
Applies to:Dream Maker
Status: Open

Issue hasn't been assigned a status value.
Descriptive Problem Summary:

Proc override order can be affected by the presence or absence of unrelated procs. Observe the difference between these two code samples:

Behavior A
/datum/foo()        return 1
/datum/proc/foo() return 2
/client/New()
..()
src << new /datum():foo()


Compiler warns:
code\sandbox.dm:5:warning: foo: procedure override precedes definition
code\sandbox.dm:6:warning: foo: definition is here

And the output is "2".

Behavior B
/datum/proc/bar()
/datum/foo() return 1
/datum/proc/foo() return 2
/client/New()
..()
src << new /datum():foo()

The compiler does not warn, and the output is "1".

Expected Results:

A specific ordering of declaration and override should produce the same result regardless of the presence or absence of proc declarations under completely different names.

Actual Results:

This unrelated proc declaration affects code generation of completely different procs on that type in a non-obvious way.

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.)

Unknown.

Workarounds:

Always put the override after the declaration. Obey DM's warnings when it deigns to emit them. Have a really good understanding of arcane compiler internals when writing proc overrides. Cross your fingers?