Just added one more test.
The code placed within a struct method isn't working too:
static STest STest::TestMethod() { STest result(1.1, 2.2); STest result2 = result.SelfMod(2); result.Log("called from STest::TestMethod"); result2.Log("called from STest::TestMethod"); //method chaining test: result.SelfMod(2).Log("called from STest::TestMethod"); return result; };
the attached file contains the combined tests.
Files:
structReturnBug.mq5
3 kb
Thank you for your message. Fixed.
Please try the new compiler version.
Please try the new compiler version.
Files:
MQL5.zip
1063 kb
MQL564.zip
1366 kb
Wow, that was fast, a big thank you!
IT IS WORKING NOW :-)

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello,
this bug took me some days to catch.
The same code executed from Onstart() works, but from a method or function does NOT.
Here is the Script code:
The above code Prints:
STest:{5.1, 4.2, called from OnStart}
STest:{3.1, 3.2, called from OnStart}
STest:{3.1, 3.2, called from OnStart}
STest:{0, 0, called from TestFunction}
STest:{0, 0, called from TestFunction}
STest:{3.1, 3.2, called from TestFunction}
STest:{0, 0, called from CTest::TestMethod }
STest:{0, 0, called from CTest::TestMethod }
STest:{3.1, 3.2, called from CTest::TestMethod }
The lines with the red values (0 ,0) are wrong!
In the above code I'm forced to write a standard and copy constructor for the struct, to be able to compile the script, even thought I'm not using them.
Hope that helps to improve mql5 and that you can fix it.
Daniel