Advertisement

import + function with default argument

Started by February 23, 2013 09:19 AM
1 comment, last by WitchLord 11 years, 9 months ago
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.

Games are meant to be created, not played...

There's definitely something wrong here. I'll look into it.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement

I've fixed this in revision 1572. Thanks.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement