V82(A): Bug with the 'Alias' keyword.

Monkey Forums/Monkey Bug Reports/V82(A): Bug with the 'Alias' keyword.

ImmutableOctet(SKNG)(Posted 2014) [#1]
I'm not sure if you've read my forum post(s) before, Mark; but since it's been a week with no response, I'll post a reminder:

If you have already read my post about this, disregard most of this post.

The 'Alias' keyword is partially broken in V82(A), the '_env' variable is not exactly handled properly. I assume this wasn't an issue due to the original structure of the 'Alias' keyword's implementation, but it's an issue now.

I have already posted a solution in my second post; all you need to do is call 'PushEnv' and 'PopEnv'. I have been using this fix for a week now, and have had no problems thus far.

For reference, here's the post I'm referring to:

In hindsight, I have actually found one somewhat small problem with the new version of 'trans'.

It would seem that the 'Alias' keyword can cause the compiler to crash with this version. It seems to be related to this line, and especially this line.

After a not so quick look at this, I realized the effect you were looking for might be better handled with 'PushEnv' and 'PopEnv'. After testing this, I can confirm that this fixed the problem in the situation I tested. From what I understand, the crash was from a chain of events, which begin at lines 1633 and 1644 of 'trans.parser' (The 'ParseMain' method's 'Alias' code). Basically, the entire issue is that '_env' is being set to 'Null', instead of being restored. So, when '_env' is used later (By the preprocessor), you get a memory access violation. Weirdly enough, this problem can only be seen from the preprocessor of the module doing the importing of the module which has the aliases in question. If the first module / build file has aliases, there's no issue (For that module, I'm pretty sure this will still happen anyway).

The fix would be something like this (This may require more testing):


Basically, I just restore the old version of '_env', so we don't have any issues.

Here's an example which will cause this issue:

"module01.monkey":


"module02.monkey":


Assuming I understood the point of all of that, my fix should work just fine. It doesn't have any issues with the above example. I had a hell of a time debugging this (And not in a good way), so here's hoping this is the last of that for now.