Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

import + function with default argument


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Wipe   Members   -  Reputation: 235

Like
0Likes
Like

Posted 23 February 2013 - 03:19 AM

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.

Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3199

Like
0Likes
Like

Posted 23 February 2013 - 09:25 AM

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

#3 Andreas Jonsson   Moderators   -  Reputation: 3199

Like
0Likes
Like

Posted 23 February 2013 - 01:17 PM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS