ID:2853662
 
BYOND Version:514
Operating System:Linux
Web Browser:Firefox 109.0
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
Descriptive Problem Summary:
When accessing a member of a global member var, its containing object is unnecessarily accessed as well.


Numbered Steps to Reproduce Problem:

1. Compile the first program
2. Disassemble it
3. Run the second program and observe the output

(The issue was discovered in the first way. The second program shows an observable consequence of the issue, which otherwise would be unobservable)

Code Snippet (if applicable) to Reproduce Problem:

Simplest code showing the odd assembly code:
var/foo/X
foo/var/global/bar/Y
bar/var/Z
proc/foo()
world.log << X.Y
world.log << X.Y.Z


Showing the null weirdness:
var/baz/W
baz/var/foo/X
foo/var/global/bar/Y
bar/var/Z
world/New()
world.log << "a [W.X.Y] b"
world.log << "c [W.X.Y.Z] d"


Expected Results:
Both X.Y and X.Y.Z access global variable Y directly.

The second program either prints "a b c d" or crashes immediately, depending on the desired null-checking behaviour.

Actual Results:
The disassembly for the first program shows X.Y compiles as a global variable access to Y, without accessing X.
However, X.Y.Z compiles as a global variable access to X, then global variable access to Y, then member variable access to Z.

The second program prints "a b" and then crashes.

Does the problem occur:
Every time? Or how often? Every time
In other games? The issue was discovered in /tg/station code.
In other user accounts? N/A
On other computers? probably

When does the problem NOT occur?
When the last variable in the chain is global.

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

Workarounds:
Make the variable actually global; or ignore it and accept a very small loss of performance and very slightly bigger DMB files.