Bug? Warning for an unused variable that does not exists

LucaMs

Expert
Licensed User
Longtime User
upload_2017-6-25_6-26-32.png


The warning points to that line, 297.
A variable named nick does not exist.
Searched "nick" in the module (with "Match case" and "Match whole word") and it does not exist.

Cleaned the project, closed and opened it again, the warning is still there.
 

LucaMs

Expert
Licensed User
Longtime User
Please upload the project.
It's a very big project (and my main project ;)).

I tried many many things:

1) renamed the routine (StartGame), using the "refactoring" and directly;
2) deleted lines apparently empty (and spaces, here and there);
3) recreate the project, using again b4j 5.51, both importing all modules and importing all module except that module, creating it again and "pasting" its texts;
4) same of above using b4j 5.00 and b4j 4.20

It was (and is) still there :D
 

LucaMs

Expert
Licensed User
Longtime User
Solved.

I had a loop like:
B4X:
For Each Nick As String In mapPlayers.Keys
Next

and I used that variable, Nick. After some change I no longer needed it (I no longer needed the variable but still the loop, which now I replaced with a For Next on a List).

I didn't find the "error" because of two imperfections of that warning:

1) when I click on it, the cursor in the editor is placed on a wrong line (I tried and this happens only in this case);
2) it does not show the variable name as it is but with all lower case characters (so I was not able to find the right line).


Thank you
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
1) when I click on it, the cursor in the editor is placed on a wrong line (I tried and this happens only in this case);
You can reproduce the wrong "behavior of the warning msg":

In a routine declare a variable and don't use it.
In the same routine write a For Each loop, using again an unused variable (well declared in the For Each statement)

If you click on the first warning the cursor of the editor will be placed correctly on the variable declaration line;
if you click on the second warning, it will be placed on the routine declaration.



2) it does not show the variable name as it is but with all lower case characters (so I was not able to find the right line).
Searched "nick" in the module (with "Match case" and "Match whole word")
Next time I will set only the second search option ;)
 
Last edited:
Top