Sign in to follow this  
Wipe

import + function with default argument

Recommended Posts

Default argument ignored(?) when imported function is using it. In case of int, no matter what value was given in function declaration, it's always 0.
// module 1
import void test2( bool dummy, int x = -1 ) from "test2";
	
void test( bool dummy, int x = -1 )
{
	Log( "x = "+x );
}

void check()
{
	Log( "TEST" );
	test( true );
	test( true, -2 );
	test( true, 2 );
	Log( "TEST2" );
	test2( false );
	test2( false, -2 );
	test2( false, 2 );
}

// module 2
void test2( bool dummy, int x = -1 )
{
	Log( "x = "+x );
}
Output is:
TEST
x = -1
x = -2
x = 2 
TEST2
x = 0
x = 0
x = 0 
Code above may refuse to compile for some reason. I got or crashes, or infinite loop (or maybe it just looks like this for me) on scripts loading (with both loading from source or bytecode), or no problems at all. Tested with r1558 and r1563.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this