"Go to Definition" very flaky in MQL5

 

I'm finding MQL5/MetaEditor5 (build 3020) is pretty inconsistent on some things. 

I'd say I can rely on the ALT-G "Go to Definition" feature to work maybe half the time in MQL5. In 4 it would always work unless I'd supremely screwed up the code somehow.

I could code calls in 4 to a function that had been coded and debugged long before, and as long as it existed somewhere in the .mq4 or #included .mqh files, ALT-G on the function name just coded worked immediately, no recompile required. And if it didn't work, I knew I had coding errors, so once they were fixed and I got a clean compile, of course ALT-G  on the function name I'd just coded would work fine. 

In 5, even after a clean compile, ALT-G often doesn't work. Just sits there looking at the function call.

Even weirder, when it doesn't work it often involves a function coded right there in the .mq5 file I'm editing, but at the same time ALT-G works for calls to other functions coded in #included .mqh files that I don't even have open.

This one is frustrating as hell, and it's really impacting my work. I use ALT-G heavily to mentally track code expectation during development. All I can do now when it doesn't work is do a "Find in Files" on the function name and scan the list for the function definition.

I hope there's some way to get this to work consistently. Anyone know a fix?

 

I never have this behaviour, except if there is an error in the code ( Build <3020, didn't work much with 3020 yet).

Can you reproduce the problem ?

 
Alain Verleyen:

I never have this behaviour, except if there is an error in the code ( Build <3020, didn't work much with 3020 yet).

Can you reproduce the problem ?

Oh yeah, easily reproducible. I'll monkey around with it tomorrow. I noticed that I can't look at code in a private class function and ALT-G to the definition of a public variable it modifies, so class/private/public considerations might be involved. Although it makes no sense to me why a public variable could not be ALT-G-d to from anywhere. Kinda implied by "public" right?

Yeah it would happen in 4 if there were coding errors, too, but they had to be so bad that the compiler couldn't make much sense out of anything

In 5, I can add a line to an .mq5 that's already clean compiled and invoke an already established, bug-free function residing in the same .mq5 file, and immediately after writing it ALT-G-ing on the function name to go to the function header does nothing. MQL4 always worked in a case like that.

 
For me this happens in anything that I put inside a macro (ifdef) which is not defined in that same file. No problems in code or compilation in any case, either with defined or undefined macro, but alt-G won't work wherever the macro conditions aren't met
 

OK, this is very simple. It's got nothing to do with classes/public/private/macros or anything beside declaration placement.

If I declare a public variable above the line of code that refers to it (i.e., the line number of declaration < line number of reference) everything works like I'd expect.

1 #property strict
2 int iTst;
3 void OnStart()
4   {
5    iTst=0;
6   }

ALT-G on "iTst" @ line 5 jumps to and highlights line 2.


If I declare a public variable below the line of code that refers to it (i.e., the line number of declaration > line number of reference), ALT-G is useless.

1 #property strict
2 void OnStart()
3   {
4    iTst=0;
5   }
6
7 int iTst;

Proof that the editor knows iTst is there regardless that its declaration is on line 7 (this is after coding with no compile attempted yet):

Even though the editor knows exactly where it is, even though it compiles and runs just fine.

Not cool.

How do you report a bug to the developers?

 

A little more. When it comes to variable declaration, MQL4 does the same as MQL5. As far as I'm concerned, both are inexplicable from a development/usability standpoint. Who wouldn't have covered this base as a conscientious coder?

But when it comes to function declaration MQL5 took a step backwards. In MQL4 it doesn't matter if you declare a function above or below a reference to it, both typeahead and ALT-G work just fine.

In MQL5 if the function declaration precedes a reference to it, ALT-G works. If the function was declared below references to it, ALT-G will not work for any those references above, even though typeahead works just fine.

 

Definitely is a bug, and it didn't use to be before (hadn't noticed fully as I'm now used to do things with includes and classes)

If it's fixed as almost any other "inconvenient" issue which is not crytical, either it takes very long, or doesn't get fixed and some admin tells us "hey fix your bad programming habits"

 
skeptic23:

A little more. When it comes to variable declaration, MQL4 does the same as MQL5. As far as I'm concerned, both are inexplicable from a development/usability standpoint. Who wouldn't have covered this base as a conscientious coder?

But when it comes to function declaration MQL5 took a step backwards. In MQL4 it doesn't matter if you declare a function above or below a reference to it, both typeahead and ALT-G work just fine.

In MQL5 if the function declaration precedes a reference to it, ALT-G works. If the function was declared below references to it, ALT-G will not work for any those references above, even though typeahead works just fine.

Manuel Alejandro Cercos Perez:

Definitely is a bug, and it didn't use to be before (hadn't noticed fully as I'm now used to do things with includes and classes)

If it's fixed as almost any other "inconvenient" issue which is not crytical, either it takes very long, or doesn't get fixed and some admin tells us "hey fix your bad programming habits"

Build 3020 is a beta. You should not use it if you don't want to be a beta-tester.

This issue is not present in release build 2981, and has already be reported for the beta build on Russian forum.

 
Alain Verleyen:

Build 3020 is a beta. You should not use it if you don't want to be a beta-tester.

This issue is not present in release build 2981, and has already be reported for the beta build on Russian forum.

Sweet! Thanks for checking. I love being a beta tester, just wasn't fully aware that's what I'm doing lol. What's the best route to take if I come up with more, just report them here? Я не говорю по-русски, но очень хорошо перевожу в Google! 😁

Good to know it will get fixed, it's a real nuisance and time-waster! Thanks man.
 
skeptic23:

Sweet! Thanks for checking. I love being a beta tester, just wasn't fully aware that's what I'm doing lol. What's the best route to take if I come up with more, just report them here? Я не говорю по-русски, но очень хорошо перевожу в Google! 😁

Good to know it will get fixed, it's a real nuisance and time-waster! Thanks man.

Report it here specifying clearly you are using a beta.

 
Alain Verleyen:

Build 3020 is a beta. You should not use it if you don't want to be a beta-tester.

This issue is not present in release build 2981, and has already be reported for the beta build on Russian forum.

My terminal is always updating, and I never set it to download beta versions...

Is there any way to avoid it updating like that? Or to differenciate between beta version and stable if it does?

Reason: