YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
24 stars 8 forks source link

In-Game: Using optional arguments and going over the 16 argument limit results in an unexpected "Variable set failed" code error dialog #7321

Closed GameDevTosh closed 2 months ago

GameDevTosh commented 2 months ago

Description

With the removal of the argument limit from https://github.com/YoYoGames/GameMaker-Bugs/issues/6473 and the fix to feather with https://github.com/YoYoGames/GameMaker-Bugs/issues/6873, we now have an issue where using optional arguments after a certain number of arguments (assuming the old 16 limit) will cause gamemaker to throw this error:


############################################################################################ ERROR in action number 1 of Create Event for object Object1: Pop :: Execution Error - Variable set failed argument16 - read only variable? at gml_Script_abc3 (line 14) - function abc3(a,b,c,d,e,f,g,h,i,j,k,l=12,m=13,n=14,o=15,p=16,q=17,r=18,s=19,t=20,u=21,v=22,w=23,x=24,y=25,z=26) ############################################################################################ gml_Script_abc3 (line 14) gml_Object_Object1_Create_0 (line 7) - var value3 = abc3(1,2,3,4,5,6,7,8,9,10,11);

This happens in latest Beta 5.

Steps To Reproduce

Given these four functions:

///@desc Has no optional arguments.
function abc(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)
{
    return a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z;
}

///@desc Has all optional arguments.
function abc2(a=1,b=2,c=3,d=4,e=5,f=6,g=7,h=8,i=9,j=10,k=11,l=12,m=13,n=14,o=15,p=16,q=17,r=18,s=19,t=20,u=21,v=22,w=23,x=24,y=25,z=26)
{
    return a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z;
}

///@desc Has 14 optional arguments, but 12 non-optional.
function abc3(a,b,c,d,e,f,g,h,i,j,k,l,m=13,n=14,o=15,p=16,q=17,r=18,s=19,t=20,u=21,v=22,w=23,x=24,y=25,z=26)
{
    return a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z;
}

///@desc Has 17 optional arguments, but 9 non-optional.
function abc4(a,b,c,d,e,f,g,h,i,j=10,k=11,l=12,m=13,n=14,o=15,p=16,q=17,r=18,s=19,t=20,u=21,v=22,w=23,x=24,y=25,z=26)
{
    return a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z;
}

If we call them all, only abc ever executes:

var value = abc(1,2,3,4,5,6,7,8,9,10,10,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26);
show_debug_message($"Function abc passed with: {value}"); //passes

var value2 = abc2();
show_debug_message($"Function abc2 passed with: {value2}"); //fails

var value3 = abc3(1,2,3,4,5,6,7,8,9,10,11,12);
show_debug_message($"Function abc3 passed with: {value3}"); //fails

var value4 = abc4(1,2,3,4,5,6,7,8,9);
show_debug_message($"Function abc4 passed with: {value4}"); //fails

The rest error out with the error above.

Which version of GameMaker are you reporting this issue for?

IDE v2024.800.0.609 Runtime v2024.800.0.633

Which operating system(s) are you seeing the problem on?

Windows 10.0.19045.0

Which platform(s) are you seeing the problem on?

Windows

a6a5f03b-acf5-443f-88e9-3e3a8b06a270

GameDevTosh commented 2 months ago

Upon further testing, if we add these new functions:

///@desc Has 1 optional arguments, but 15 non-optional.
function abc5(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p=16)
{
    return a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p;
}
///@desc Has 1 optional arguments, but 16 non-optional.
function abc6(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q=17) 
{
    return a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q;
}

And test them, the first will pass, but not the second:

var value5 = abc5(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
show_debug_message($"Function abc5 passed with: {value5}"); //passes

var value6 = abc6(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);
show_debug_message($"Function abc6 passed with: {value6}"); //fails

So it seems to be an issue with setting optional arguments after the 16 limit.

rwkay commented 2 months ago

Fixed in 2024.10

mgeddesGM commented 1 month ago

verified as of IDE v2024.1100.0.625 Runtime v2024.1100.0.651