ID:2935930
 
BYOND Version:515
Operating System:Linux
Web Browser:Firefox 128.0
Applies to:Dream Maker
Status: Deferred

This issue may be low priority or very difficult to fix, and has been put on the back burner for the time being.
Descriptive Problem Summary:
BYOND gets confused when tricked into accessing a global variable on an object instance

Numbered Steps to Reproduce Problem:
1. Create a global variable
2. Create an instance of something
3. Try to access a value on the something but put the variable name on a newline
4. Run the code

Code Snippet (if applicable) to Reproduce Problem:
var/list/glob = list(1,2,3)

/world/New()
..()
var/obj/inst = new
for(var/l in inst.
glob) {world.log << l}
shutdown()


Expected Results:
Either listing 1,2,3 or some sort of syntax error

Actual Results:
BYOND enters an infinite loop where it loops over an infinite list of nulls

Does the problem occur:
Every time? Or how often? Yes
In other games? N/A
In other user accounts? N/A
On other computers? Dunno
occur?

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.) It has always occurred

Workarounds:
Not doing this sort of wacky syntax
Lummox JR changed status to 'Deferred'
I'm reassigning this as a compiler bug and shelving it.

The reason you're having an infinite loop is that the compiler is compiling the condition in your for() as two separate statements, and thinking it's actually this:

for(l in inst, glob,)

Since the global value is always true, you've got an infinite loop.

There are multiple reasons your code shouldn't compile, which is what makes this a compiler bug. But it's actually behaving correctly at runtime based on what the compiler thinks it's compiling.