Page MenuHomeFeedback Tracker

Passing in a argument with the wrong type into Params
Acknowledged, WishlistPublic

Description

If you pass in a wrong type into Params it will show an error message and halt the script. Stopping the script from running due to the error.

Expected functionality is the script continues to run with default values and params will return false. However this is prevented from happening.

This bug started happening on the new Arma 3 Perf binary (v5) 1.52.133024

Details

Legacy ID
555616983
Severity
None
Resolution
Open
Reproducibility
Always
Category
Scripting
Steps To Reproduce

_data = [0];
_data params "_killDistance","0",[""];

Additional Information

This code above will fail because a int is passed in instead of the expected type which is a string.

Event Timeline

Deathlyrage edited Additional Information. (Show Details)
Deathlyrage set Category to Scripting.
Deathlyrage set Reproducibility to Always.
Deathlyrage set Severity to None.
Deathlyrage set Resolution to Open.
Deathlyrage set Legacy ID to 555616983.May 8 2016, 1:00 PM
Deathlyrage edited a custom field.

Yes, unfortunately params functionality has been changed and now it is not possible to suppress errors as before. However there are 4 Type specific commands added to deal with type of function input, which are also fast.

isEqualType, isEqualTypeArray, isEqualTypeAll, isEqualTypeParams (look up on BIKI)

for your particular example

if !(_this isEqualTypeParams [0]) exitWith {..this will run if _this is not [SCALAR]};

if !(_this isEqualTypeParams [""]) exitWith {..this will run if _this is not [STRING]};

I don't get the point of params returning a boolean if it failed or not If it will just throw a error message and halt. But that's understandable if its intended functionality.

It now only errors when type is wrong. It will still quietly return false if undefined input has been substituted with default value.

Ok Feel free to close this report.

When script command has a wrong input it throws an error and halts further code execution. That's a normal behavior.

In case of param and params commands we could make an exception to use default value and continue code execution if the default value is provided.

If it would be a new command we probably wouldn't go this way and halt the execution, like it is done anywhere else where the wrong input occurs. Because of the backward compatibility (with bis_fnc_param) we will change the behavior of those 2 commands so they will use the default value even if the input type is wrong.

But seriously, you should know what the command is inspecting and send correct data type there.

Bohemia added a subscriber: Bohemia.May 8 2016, 1:00 PM

https://community.bistudio.com/wiki/params
Was meant to replace BIS_fnc_params
With the latest change it no longer a dropin replacement.

This functional was nice to have it.
For instance when the incoming data i.e from a client to server.
Where you cant trust the data + datatypes 100%.

-----------------------------------------------

Honestly with the latest change, i really can't see a reason to use params.
All it does is private, replace nil value with default value & error out if wrong datatype.

I will still need to check for bad datatypes if i want the function to run, which was the only reason i ever used params.

Can we please have a boolean value to enable / disable this new behaviour change.

Thanks