Gamemaker ignores duplicate var declarations, Enigma don't.

Reporter: RodrigoCard  |  Status: open  |  Last Modified: September 19, 2016, 04:14:33 PM

I found something like this on someone else's code:

var aaa
aaa = 1
var aaa

Works on GameMaker but do not work on Enigma.

The enigma behavior seems more correct to me, but it doesnt throw any errors before trying to compile the Generated C++ code, it should at least warn the user so he can know which line to delete and fail gracefully.

RobertBColton  
I tried the following in GM 5 and GMS:

var aaa;
aaa = 1;
var aaa;

show_message(string(aaa));

It actually did the opposite of what I thought it would do. It showed me "1" but I expected it to show me "0".

In ENIGMA this gave me the following error:

C:/ProgramData/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_objectfunctionality.h: In member function 'virtual variant enigma::OBJ_obj_0::myevent_create()':
C:/ProgramData/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_objectfunctionality.h:44:9: error: redeclaration of 'var aaa'
     var aaa;
         ^

Which is expected because C++ does not allow you to redefine variables like that. This is more correct in the sense that this makes ENIGMA "safer" than GameMaker. Either way ENIGMA is failing pretty gracefully here and there isn't really an issue. I don't know if this is something the syntax checker could look for or not because the scope of var could be the entire instance.

@JoshDreamland could the syntax checker look for redeclaration of variables?

Please sign in to post comments, or you can view this issue on GitHub.