Show/Hide Toolbars

XSharp

Navigation: X# Documentation > X# Compiler Options > X# Compiler Options Listed Alphabetically

-vo9 Handle problems with incorrect or missing return statements

Scroll Prev Top Next More

The -vo9 option prevents the compiler from raising error XS0161 when a function or method does not have any RETURN statements. It also fixes problems with incorrect return values.

Syntax

-vo9[+|-]

Arguments

+ | - Specifying +, or just -vo9, allows functions and methods that do not have any RETURN statement to compile without raising an error.

Remarks

Visual Objects allows functions and methods whose return type is not VOID to omit RETURN statements. The return value from any such functions or methods will always be the default value for the return type.

 

This is illegal in X#: all functions and methods must explicitly return a value unless the return type is VOID. However, this may prevent code that was originally written in Visual Objects from compiling in X#.

 

If -vo9 is enabled, any non-void functions or methods that do not have any RETURN statements will raise warning XS9025 instead of error XS0106. The warning may be disabled if desired, but it is strongly recommended that you fix the code in question.  If the return value is never used, then type the function or method AS VOID. Otherwise, add a RETURN statement with an appropriate return value.

This compiler option also checks for methods/functions that have a return statement without value. In that case a warning XS9026 is shown.
The final check this compiler option does it for methods that have a return value but are not expected to return anything. If that is found then a warning XS9032 is shown.

To set this compiler option in the Visual Studio development environment:

 

1.Open the project's Properties page.

2.Click the Dialect tab.

3.Change the value.

4.Click here to see the property page

Example

FUNCTION x( y )
? y
 
METHOD x( y AS INT ) AS INT
? y

In the first example, the return type is not specified so it defaults to USUAL, and since there is no RETURN statement the function will always returns NIL (the default value for USUAL) in Visual Objects. In the second example, since there is no RETURN statement the method will always return zero (the default value for INT) in Visual Objects.