XS9026 Missing RETURN value. A default 'empty' return value is returned

This forum is meant for questions and discussions about the X# language and tools
Post Reply
kitz
Posts: 87
Joined: Wed Nov 29, 2017 8:56 am

XS9026 Missing RETURN value. A default 'empty' return value is returned

Post by kitz »

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
User avatar
Chris
Posts: 4907
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

XS9026 Missing RETURN value. A default 'empty' return value is returned

Post by Chris »

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:

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
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?
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
kitz
Posts: 87
Joined: Wed Nov 29, 2017 8:56 am

XS9026 Missing RETURN value. A default 'empty' return value is returned

Post by kitz »

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
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

XS9026 Missing RETURN value. A default 'empty' return value is returned

Post by FFF »

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 ;-)
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

XS9026 Missing RETURN value. A default 'empty' return value is returned

Post by robert »

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
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Chris
Posts: 4907
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

XS9026 Missing RETURN value. A default 'empty' return value is returned

Post by Chris »

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.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply