BUG? Max number of function parameters/arguments is limited to 9?

Former Member
Former Member

Hi guys,

Today I discoverd something strange in the CIQ environment, the max number of function parameters is limited to 9?

When I write a function with 10 parameters, and call it with 10 arguments accordingly, I get a  "Too Many Arguments Error".

But when I cut the parameters and arguments down to 9, the function works. The error see below.

Error: Too Many Arguments Error
Details: Failed invoking <symbol>

My environment is Mac Mojave, with the Eclipse IDE, SDK version is 3.1.8.

I ran the code in the simulator, haven't test it on real device yet, the target device is Fenix3/HR, CIQ requirement is 1.3.x, both have this error. 

I write some simple code to test this behavior, code like this with 10 parameters will end up with the Error above at the runtime.

function test_arguments(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) {
    return true;
}

function onLayout(dc) {
    test_arguments(1,2,3,4,5,6,7,8,9,10);
    ...other stuffs...
}

But when I changed it to this, with 9 parameters, it works well, everything is OK.

function test_arguments(x1,x2,x3,x4,x5,x6,x7,x8,x9) {
	return true;
}

function onLayout(dc) {
	test_arguments(1,2,3,4,5,6,7,8,9);
	....other stuffs....
}

What I'm wondering now is, is this a BUG, or it's an expected behavior?

I checked the Programing Guide provided by the SDK, no mention about this limit exist.

I know I can make a workaround on it simply by putting the excessive arguments in an array to pass more arguments,

But if this limit is a legit thing, should it better be part of the compiler check, and give a direct error at the compile time when it comes to functions with 10 and more arguments?

The error message is really confusing, it's telling you your function call has mismatched arguments number, it costs me a huge time try to track down the non-exist "problem", never thought it could be something like this... 

Somebody, please shed me some light?

  • Been the case since CIQ came out.  What you can do is maybe pass some things as an array instead of individual arguments.  If you pass lat and lon, pass it as [lat,lon] for instance.

  • Former Member
    Former Member over 5 years ago in reply to jim_m_58

    Thanks for your reply, shocked to hear nothing improved since then... The array trick is the way, that's also the way I figured out myself at last...

    It's really weird, such limitation is actually OK, even limit to 1 is still OK, but shouldn't it be a compile time thing? add some parameter number check in the compiler is a very easy thing. Or at least update the documents to make it our fault to not check it carefully.

    I came across this problem in the unittest code, a big function to check everything is set, so the "Too Many Arguments Error" is really confusing and misguiding. You have to check everything, and never suspect it's a problem within the CIQ itself.

    Hope connectIQ guys could do something about it.