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.
Attached files
structreturnbug.mq5 (2.6 KB)
68
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