ID:80703
 
Not a bug
BYOND Version:453
Operating System:Windows Vista Home Premium 64-bit
Web Browser:Internet Explorer 8.0
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
Descriptive Problem Summary:
I get this set of messages with the code below.

a
b
runtime error: Test.dme:15:Assertion Failed: i
proc name: Test (/mob/verb/Test)
usr: Superbike32 (/mob)
src: Superbike32 (/mob)
call stack:
Superbike32 (/mob): Test()
c
0


I would expect this output, given that in my code, assert is after world<<i.

a
b
c
0
runtime error: Test.dme:15:Assertion Failed: i
proc name: Test (/mob/verb/Test)
usr: Superbike32 (/mob)
src: Superbike32 (/mob)
call stack:
Superbike32 (/mob): Test()


Numbered Steps to Reproduce Problem:
1.Copy the code below to a fresh project.
2.Start it up. (Using, build>>run, it doesn't matter whether or not you previously compiled, where you compile with build>>compile, or let it compile after, the out of order messages happen.
3.Press the button and click the dialogs.
4.What was explained above happens.

Code Snippet (if applicable) to Reproduce Problem:
mob/verb/Test()
var/list/L = list("a","b","c",FALSE)
for(var/i in L)
alert(i)
world<<i
ASSERT(i)


Expected Results:
The messages should show in the correct order, so, meaning when it gets to the last item in the list, even though it does not display an alert for FALSE, the message should get sent from the world<<i code, then an ASSERT() message should display an error, since it asserts after, but the messages as shown above are out of order, and are not correct.

This maybe due to the way it handles errors, but it can be a little annoying at times to find where the error lies when the messages are in a different order than they really happened in, it could make it hard to track down when and where the bug actually originated from.

Actual Results:
The messages are in the wrong order

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

When does the problem NOT occur?If I put world<<i before the alert(i) it will show like this, but it is still not under the message 0, even thoug ASSERT() is the last statement in the code.

a
b
c
runtime error: Test.dme:15:Assertion Failed: i
proc name: Test (/mob/verb/Test)
usr: Superbike32 (/mob)
src: Superbike32 (/mob)
call stack:
Superbike32 (/mob): Test()
0


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:
A possible work-around is sleep() or some other code to wait for the message to be sent before the ASSERT() message, but, I would think that it would wait already for the world<<i to finish and messages to be sent before even trying to execute the next line in the verb, which is ASSERT(i)

</<i></<i></<i>
Output to world and world.log (which is used for error messages) go to different places, hence are handled differently. It is entirely possible for one to be printed a little ahead of the other, especially in the event of a runtime error. Whether this behavior could be improved is a separate question, but in any case it's a known issue and in fact the same is likely to happen in many other programming languages depending on how a program's output is handled.