[a108] Error: Invalid number of parameters. Topic is solved

Discuss the future of the AutoHotkey language
Helgef
Posts: 4450
Joined: 17 Jul 2016, 01:02
Contact:

[a108] Error: Invalid number of parameters.

11 May 2020, 11:45

Code: Select all

guicreate().onevent('close', ()=>0) ; Error:  Invalid number of parameters.
This error message is very misleading, it should say Error: Parameter #2 invalid.. The same goes for other functions (eg callbackcreate / hotkey 'if') which verifies the number of parameters for callback functions. I know this is intended but I disagree with it, it has fooled me several times.

Cheers.
swagfag
Posts: 3912
Joined: 11 Jan 2017, 17:59

Re: [a108] Error: Invalid number of parameters.

11 May 2020, 12:41

yes, the messages should be combined. "Parameter #2 invalid" on its own is only marginally better than "Invalid number of parameters.", in both cases ud to have already known what the error refers to in order to be able to fix it
Helgef
Posts: 4450
Joined: 17 Jul 2016, 01:02
Contact:

Re: [a108] Error: Invalid number of parameters.

11 May 2020, 13:42

. "Parameter #2 invalid" on its own is only marginally better than "Invalid number of parameters."
Parameter #2 invalid tells you that there is something wrong with ()=>0. So I read the documentation on this parameter, and find the answer.
Invalid number of parameters, tells you there is something wrong with the number of parameters of guicreate() or .onevent(). So I read the docs on onevent and count the number of parameters it takes, this doesn't solve the problem.

Invalid number of parameters for callback function would probably be more helpful, or perhaps just invalid callback function.
User avatar
kczx3
Posts: 1119
Joined: 06 Oct 2015, 21:39

Re: [a108] Error: Invalid number of parameters.

11 May 2020, 16:59

Helgef wrote:
11 May 2020, 13:42
or perhaps just invalid callback function.
👍🏻 Simple and concise
swagfag
Posts: 3912
Joined: 11 Jan 2017, 17:59

Re: [a108] Error: Invalid number of parameters.

11 May 2020, 18:17

and yet vague all the same. it clearly knows the problem is with the callback's parameter count, so it should say so. this requires refactoring the ValidateFunctor function though
User avatar
TheArkive
Posts: 323
Joined: 05 Aug 2016, 08:06
GitHub: TheArkive

Re: [a108] Error: Invalid number of parameters.

26 May 2020, 04:15

Invalid number of parameters in callback function. ???

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: No registered users and 9 guests