vscode-sqflint
vscode-sqflint copied to clipboard
Wrong undefined variable in CBA_fnc_addEventHandlerArgs
_thisArgs
, _thisType
, _thisId
are always marked as possibly undefined variables.
Example where all occurances are marked after indexing:
["KPLIB_build_stop", {
[_thisType, _thisId] call CBA_fnc_removeEventHandler;
_thisArgs params ["_openEhId", "_builtEhId"];
["KPLIB_build_display_open", _openEhId] call CBA_fnc_removeEventHandler;
["KPLIB_build_item_built_local", _builtEhId] call CBA_fnc_removeEventHandler;
}, [_openEhId, _builtEhId]] call CBA_fnc_addEventHandlerArgs;
They should be fine, due to the CBA function. Ref:
Registers an event handler for a specific CBA event with arguments.
A event added with this function will have the following variables defined:
_this - Arguments passed by function calling the events. <ANY>
_thisArgs - Arguments added to event by this function. <ANY>
_thisId - Same as the return value of this function. <NUMBER>
_thisType - Name of the event. (Same as _eventName passed to this function) <STRING>
_thisFnc - Piece of code added to the event by this function <CODE>
Very weird is, that they're even marked as possibly undefined, although we've added them in our workspace settings to be ignored
"sqflint.ignoredVariables": [
// ...
"_thisArgs",
"_thisId",
"_thisType",
// ...
Just an update with some more information on this:
Files for reference: https://github.com/KillahPotatoes/KP-Liberation/blob/v0.97S13/Missionframework/modules/14_virtual/fnc/fn_virtual_initCuratorOnPlayer.sqf
https://github.com/KillahPotatoes/KP-Liberation/blob/v0.97S13/Missionframework/modules/15_build/fnc/fn_build_start_single.sqf
It's hard to catch all those dynamically defined variables, I think the more futureproof solution would be to add possibility to "define" variables in comments ... like this maybe? (I think I've already mentioned this somewhere else)
/*
@define _thisArgs ARRAY
@define _thisType STRING
....
*/
Anyway, marking this as a bug, since the "ignoredVariables" setting should hide those warnings, I have to take a look what's the issue there