This repository has been archived by the owner on Aug 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
type hinting #44
Comments
From the code alone, I would argue that _foo should be |
$ python sqflint.py <<SQF
> _foo = ["methodName", _parameters] call {
> _this call (uiNamespace getVariable ["myScript", {}]);
> };
> if (_foo == "bar") then {
> hint "x";
> };
>
> SQF
[1,22]:warning:Local variable "_parameters" is not from this scope (not private)
[1,0]:warning:Local variable "_foo" assigned to an outer scope (not private)
[4,4]:warning:Local variable "_foo" is not from this scope (not private)
[4,9]:error:Binary operator "==" arguments must be [(String,String),(Config,Config),(Display,Display),(Control,Control),(TeamMember,TeamMember),(NetObject,NetObject),(Task,Task),(Location,Location),(Number,Number),(String,String),(Object,Object),(Group,Group),(Side,Side)] (lhs is Nothing, rhs is String)
🤷♂️ |
Let me re-phrase: my argument is that this is a bug in the Linter: _foo should be Anything, not Nothing. |
yes. so on further experimentation, it seems tthat _foo = call {
call foo;
};
// _foo is Nothing _foo = call {
call foo
};
// _foo is Anything |
Now I see. So, we take the last statement of call to take its return type. It happens that the Linter currently takes ; to denote when we want to return Nothing instead of Anything (wrongly). As a consequence, it made _foo to be Nothing. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hey,
is there any way I can tell sqflint to assume a certain type for a var?
Explanation:
I'm working with some code that is… rather dynamic, as in:
…after which sqflint assumes _foo to be of type
Nothing
.Which is not very helpful, because it will then go and cry wolf at every corner.
Being able to hint to a type would be neat, for example:
The text was updated successfully, but these errors were encountered: