Hello!
I don't understand this warning in my case:
METHOD mymethod(par1, par2)
….( no additional RETURN in the body)
RETURN VOID
I think I already specified a return value?
This is from compiling a VOXported library.
BR Kurt
XS9026 Missing RETURN value. A default 'empty' return value is returned
XS9026 Missing RETURN value. A default 'empty' return value is returned
Hi Kurt,
This probably needs some adjustment in the compiler, but currently it seems it does not regard VOID as a "valid" return value. Try RETURN NIL instead for now and it will not warn anymore.
An important thing to note is that when you "RETURN VOID", you do not really return "nothing". Instead you return a numeric value. Try this in VO, every data type keyword has a corresponding numeric "value", which maps to the UsualType of the type it represents:
So in fact, when you use RETURN VOID, it is equivalent to using "RETURN 0". You can confirm this by running this in both X# and VO:
I am not sure what the correct behavior should be in X#:
a) Make the compiler not report a warning anymore and let it still return zero, like it already does (and like VO does)
b) Let it still report a warning, because the programmer might have accidentally used this VOID return value, but improve the warning text?
What do you (and anybody else of course) think?
This probably needs some adjustment in the compiler, but currently it seems it does not regard VOID as a "valid" return value. Try RETURN NIL instead for now and it will not warn anymore.
An important thing to note is that when you "RETURN VOID", you do not really return "nothing". Instead you return a numeric value. Try this in VO, every data type keyword has a corresponding numeric "value", which maps to the UsualType of the type it represents:
Code: Select all
FUNCTION Start() AS INT
? VOID // 0
? INT // 1
? DATE // 2
? SYMBOL // 10
? USUAL // 18
? ARRAY // 5
? UsualType(NULL_ARRAY) // 5
? STRING // 7
? UsualType("") // 7
WAIT
RETURN 0
So in fact, when you use RETURN VOID, it is equivalent to using "RETURN 0". You can confirm this by running this in both X# and VO:
Code: Select all
FUNCTION Start() AS INT
? TestVoid() // 0
? TestDword() // 14
WAIT
RETURN 0
FUNCTION TestVoid() CLIPPER
RETURN VOID // warning XS9026 in X#
FUNCTION TestDword() CLIPPER
RETURN DWORD // no warning
a) Make the compiler not report a warning anymore and let it still return zero, like it already does (and like VO does)
b) Let it still report a warning, because the programmer might have accidentally used this VOID return value, but improve the warning text?
What do you (and anybody else of course) think?
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
XS9026 Missing RETURN value. A default 'empty' return value is returned
Chris,
thanks, it works with NIL.
I have an old app (~20 yrs) I had in VO2740, then moved to VO2838 and now begin to move it to XSharp.
I didn't modify using the dbserver editor in VO2838, now I did and it created NIL at every return.
This newly transported works well.
I don't know really which way this should be enhanced, for me it's ok now like it is.
BR Kurt
thanks, it works with NIL.
I have an old app (~20 yrs) I had in VO2740, then moved to VO2838 and now begin to move it to XSharp.
I didn't modify using the dbserver editor in VO2838, now I did and it created NIL at every return.
This newly transported works well.
I don't know really which way this should be enhanced, for me it's ok now like it is.
BR Kurt
XS9026 Missing RETURN value. A default 'empty' return value is returned
Chris,
while i think any coder which used a returned "pseude-void" gets what he deserves
- i'm for b). The actual text is simply wrong & misleading. Let it contain the hint to "NIL" and hint to "VOID = 0". Additionally some lines in the help wouldn't harm ![Wink ;-)](https://dt9qzg9h465rt.cloudfront.net/phpBB3/images/smilies/icon_e_wink.gif)
while i think any coder which used a returned "pseude-void" gets what he deserves
![Wink ;)](https://dt9qzg9h465rt.cloudfront.net/phpBB3/images/smilies/icon_e_wink.gif)
![Wink ;-)](https://dt9qzg9h465rt.cloudfront.net/phpBB3/images/smilies/icon_e_wink.gif)
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
XS9026 Missing RETURN value. A default 'empty' return value is returned
Karl,
If you have a suggestion for how it should be phrased in the help file, then I'll copy and paste it to the help.
The same is true for the error message.
Btw: VOID in RETURN VOID is seen as "NO value" and not the numeric value of the VOID keyword.
This is because some people write code for procedures that RETURN VOID.
I can probably change that if this causes too much noise.
Robert
If you have a suggestion for how it should be phrased in the help file, then I'll copy and paste it to the help.
The same is true for the error message.
Btw: VOID in RETURN VOID is seen as "NO value" and not the numeric value of the VOID keyword.
This is because some people write code for procedures that RETURN VOID.
I can probably change that if this causes too much noise.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
XS9026 Missing RETURN value. A default 'empty' return value is returned
Robert,
I don't think it causes too much noise, it's probably a very rare thing.
But RETURN VOID does actually return zero, both in VO and in the current X# compiler, you can see that by running the code I posted earlier.
I don't think it causes too much noise, it's probably a very rare thing.
But RETURN VOID does actually return zero, both in VO and in the current X# compiler, you can see that by running the code I posted earlier.
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu