ASH is supposed to detect when you have a non-void function which doesn't return a value of the correct type and give you a compile error.
I see the following code in Parser.parseFunction().
So, it intentionally fails to do that for boolean functions (for some unknown reason), but should make that check for non-boolean functions.
However, the following script shows that ASH's return value checking is busted for non-booleans:
This fails validation with "missing return value".
If you declare that a function returns a value, ASH should enforce that you do that - for all data types, not just non-booleans. In order to do that, it will need to understand that certain control constructs can make following statements unreachable and not simply check that the last statement in the function is a "return".
I see the following code in Parser.parseFunction().
Code:
if ( !result.assertReturn() && !functionType.equals( DataTypes.TYPE_VOID )
// The following clause can't be correct. I think it
// depends on the various conditional & loop constructs
// returning a boolean. Or something. But without it,
// existing scripts break. Aargh!
&& !functionType.equals( DataTypes.TYPE_BOOLEAN ) )
{
throw this.parseException( "Missing return value" );
}
So, it intentionally fails to do that for boolean functions (for some unknown reason), but should make that check for non-boolean functions.
However, the following script shows that ASH's return value checking is busted for non-booleans:
Code:
int test()
{
if ( true )
return 1;
}
This fails validation with "missing return value".
If you declare that a function returns a value, ASH should enforce that you do that - for all data types, not just non-booleans. In order to do that, it will need to understand that certain control constructs can make following statements unreachable and not simply check that the last statement in the function is a "return".
Last edited: