Plugin:CreatePluginAction() gives incorrect warning when first argument indexes something and 5th argument is not the same type as 6th argument

A detailed description - If you attempt to provide incorrect plugin:CreatePluginAction() arguments and the first of these incorrect arguments are a member of a table and the last argument is different from the other types, you get an incorrect error, “This function does not take self. Did you mean to use a dot instead of a colon?”. The correct warning message should be argument count mismatch.

Where it happens - Studio only.

When it happens - Only noticed it now, June 9th at 12:52 AM AST.

Videos and images

Reproduction instructions -
This should reproduce the issue 100% of the time:

1- Define ‘plugin’'s type as Plugin like so:

local plugin: Plugin = plugin

2- Attempt to call plugin:CreatePluginAction when the first of these arguments is indexing something. This index can but doesn’t have to index a real object. t[1] where t is nil will reproduce the issue, as well as when t is an actual table.

3- Provide any 4 more arguments after this, like so:
image

4- Now, as the 5th argument, add a value that is not equal to the fourth argument but ensure this fourth argument is incorrect (a string, instance, nil, anything except a boolean.

5- Now, provide a 6th argument. This argument should not be the same type as the 4th argument. It can be anything, this will reproduce the issue.
image

Code to reproduce -

local plugin: Plugin = plugin

plugin:CreatePluginAction(a, '', '', '', '', nil)

This seems like it is working as expected. CreatePluginAction only has 5 arguments. When you add a sixth argument, the only case where that would only be valid is if you called the method using the dot notation rather than colon. I.e.:

plugin.CreatePluginAction(plugin, a1, a2, a3, a4, a5)

colon call notation is only an alias for the above which passes the object you’re calling it on as the self argument. This warning is telling you that this function expects to be called without self (i.e. a table-based first argument) with normal colon notation. You will not get this error if the function is called appropriately with only 5 arguments.

2 Likes