Reporter: RobertBColton | Status: closed | Last Modified: September 10, 2020, 07:57:37 pm
What I am reporting here is an issue pointed out to me by @Darkstar2 over Discord. `goto` is only working in object events andnot scripts due to a parsing issue. For some reason, JDI is converting the label identifiers into a var access causing compile to fail. It's possible that some of sorlok's changes in #912 may be related as I notice that he did change how variables are collected with respect to goto.
```cpp
goto my_special_label;
return0;
my_special_label:
show_message("hello!");
C:/Users/Owner/AppData/Local/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_objectfunctionality.h: In function 'variant _SCR_scr_0(variant, variant, variant, variant, variant, variant, variant, variant, variant, variant, variant, variant, variant, variant, variant, variant)':
C:/Users/Owner/AppData/Local/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_objectfunctionality.h:41:16: error: expected ';' before '::' token
goto enigma::varaccess_my_special_label(int(self));
^~
;
C:/Users/Owner/AppData/Local/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_objectfunctionality.h:41:18: error: '::varaccess_my_special_label' has not been declared
goto enigma::varaccess_my_special_label(int(self));
^~~~~~~~~~~~~~~~~~~~~~~~~~
C:/Users/Owner/AppData/Local/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_objectfunctionality.h:41:18: note: suggested alternative:
In file included from SHELLmain.cpp:105:
C:/Users/Owner/AppData/Local/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_objectaccess.h:52:9: note: 'enigma::varaccess_my_special_label'
var &varaccess_my_special_label(int x)
^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from SHELLmain.cpp:106:
C:/Users/Owner/AppData/Local/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_objectfunctionality.h:43:50: error: expected ';' before ':' token
enigma::varaccess_my_special_label(int(self)):
^
;
C:/Users/Owner/AppData/Local/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_objectfunctionality.h:41:10: error: label 'enigma' used but not defined
goto enigma::varaccess_my_special_label(int(self));
^~~~~~
It's important to recognize that JDI is just the C++ comprehension layer. This is what I'm always bitching at fundies about. JDI interprets C++, so if a function or type is not known to ENIGMA, that is likely a JDI problem. But all other parsing concerns are a problem with ENIGMA's EDL parser/syntax checker.
This can be confusing, because adding a semicolon to the wrong place can be either. It could be ENIGMA not recognizing a declaration because JDI mis-reported a type, or it could be the parser just shitting the bed. After new JDI has been merged, it will be much more likely to be the latter.
In this case, it's pretty obviously a parser problem. The parser isn't classifying labelname: as a label in scripts. This makes sense to me, as it's not something I programmed it to do. It wouldn't be all that hard to fix, but:
The current parser is what we'll call "sunsetting." At the point where I'm literally maintaining a C++ compiler, there's no excuse to outsource any parsing responsibilities to GCC. The EDL comprehension layer should be what Rusky wanted it to be way back in the day.
Use of goto is frowned upon in every programming community. I'm not super sad we broke it somehow. Chances are, whatever you're doing with goto is better accomplished with a break statement or a conditional. This isn't always the case, which is why I attempted to leave goto in the language. But other export languages (such as JavaScript) don't support goto, so it's better that we drop support for it early.
1. It's your fault for we call compiler JDI because you have no branding on it. Come up with a name for the compiler because when you say compiler error or bug you think GCC.
I found a workaround that makes it work if you just want to use it. Declare your label as a var, that stops JDI from adding the varaccess stuff. Works for me on master.
var my_special_label;
goto my_special_label;
return0;
my_special_label:
show_message("hello!");
```